Managing Actions

Disable/Enable Actions

In the example in the previous lesson, if the user clicks the Next or Previous buttons on the application form without first querying successfully, a message displays and no action is taken. You can disable and enable the actions instead, providing visual cues to the user when the actions are not available.

The ui.Dialog built-in class provides an interface to the BDL interactive dialog statements, such as CONSTRUCT and MENU. The method setActionActive enables and disables actions. To call a method of this class, use the predefined DIALOG object within the interactive instruction block.

For example:

MENU
  ...
  BEFORE MENU
    CALL DIALOG.setActionActive("actionname" , state)
    ...

END MENU

where actionname is the name of the action, state is an integer, 0 (disable) or 1 (enable).

You must be within an interactive instruction in order to use the DIALOG object in your program, but you can pass the object to a function. Using this technique, you could create a function that enables/disables an action, and call the function from the MENU statement, for example. See The Dialog class in the Genero Business Development Language User Guide for further information.

The Close Action

In Genero applications, when the user clicks the

button in the upper-right corner of the application window, a predefined close action is sent to the program. What happens next depends on the interactive dialog statement.

  • When the program is in a MENU dialog statement, the close action is converted to an INTERRUPT key press. If there is a COMMAND KEY INTERRUPT block in the MENU statement, the statements in that control block are executed. Otherwise, no action is taken.
  • When the program is in an INPUT, INPUT ARRAY, CONSTRUCT or DISPLAY ARRAY statement, the close action cancels the dialog, and the INT_FLAG is set to TRUE. Your program can check the value of INT_FLAG and take appropriate action.
You can change this default behavior by overwriting the close action within the interactive statement. For example, to exit the MENU statement when the user clicks this button:
MENU
  ...
  ON ACTION close
    EXIT MENU
END MENU

By default the action view for the close action is hidden and does not display on the form.