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. The
DIALOG
object can be passed as parameter to a function as ui.Dialog parameter, and
can be used in that function to reuse code.
A good programming pattern is to centralize action activation in a function that takes the ui.Dialog object and activation conditions as parameters:
...
MENU "Customer"
BEFORE MENU
CALL setup_dialog(DIALOG,FALSE)
...
PRIVATE FUNCTION setup_dialog(dlg ui.Dialog, can_nav BOOLEAN) RETURNS ()
CALL dlg.setActionActive("next",can_nav)
CALL dlg.setActionActive("previous",can_nav)
END FUNCTION
Go to The Dialog class in the Genero Business Development Language User Guide for further information.