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, theclose
action is converted to anINTERRUPT
key press. If there is aCOMMAND KEY
INTERRUPT
block in theMENU
statement, the statements in that control block are executed. Otherwise, no action is taken. - When the program is in an
INPUT
,INPUT ARRAY
,CONSTRUCT
orDISPLAY ARRAY
statement, theclose
action cancels the dialog, and the
is set toINT_FLAG
TRUE
. Your program can check the value of
and take appropriate action.INT_FLAG
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.