Changing Modes and Values at Callback Time
 
 
 

At callback time, you can check the value of a tile. If necessary, you can use set_tile again to modify this value. During callbacks, you can also use mode_tile to change the status of a tile. The following table shows the values of the mode_tilemode argument:

Mode codes for mode_tile

Value

Description

0

Enable tile

1

Disable tile

2

Set focus to tile

3

Select edit box contents

4

Flip image highlighting on or off

When you use mode_tile to disable a tile that has the current focus, you must call mode_tile again to set the focus to a different tile (in most cases, the next tab stop in the dialog box). Otherwise, the focus will remain on a disabled tile, which is illogical and can cause errors.

A good example of a tile disabling itself is a series of dialog box pages that the user steps through by choosing a Next or Previous button. When the user chooses Next on the next-to-last page, the button is disabled. The same thing happens after choosing Previous on the second page. In both cases, the code must disable the button that was chosen, and then set focus to a different tile.

Suppose the tile called group_on is a toggle that controls a cluster called group. When the toggle is turned off, the tiles in the cluster are inactive and should not be modified. In this case, you might define the following action for the toggle. (Notice the use of the \" control character, which allows quotation marks within an action_tile argument.)

(action_tile "group_on" "(mode_tile \"group\" (- 1 (atoi $value)))")

The subtraction and atoi call in the action expression set the mode_tile function's mode argument. Because a toggle is 0 when it is turned off and 1 when it is turned on, the subtraction inverts its value and the mode controls whether the cluster is enabled.

You can inspect attributes other than a tile's value with the get_attr function. For example, you may want to retrieve the label of a button called "pressme":

(get_attr "pressme" "label")

The get_attr function returns the value of the specified attribute as a string.

NoteIf you use get_attr to retrieve a value attribute, it gets the value attribute saved in the DCL file (the initial value of the tile). The get_tile function, however, gets the current runtime value of the tile. The two values are not necessarily the same.