User interface programming / Dialog actions |
By default, dialog actions are enabled, however an action should be disabled when not allowed in the current context.
Dialog actions are enabled to let the user invoke the action handler (ON ACTION/COMMAND) by clicking on the corresponding action view (button) or by pressing its accelerator key. In most situations, actions remain active during the whole dialog execution. However, to follow GUI standards, actions must be disabled when not allowed in the current context. For example, a print action should be disabled if no record is currently shown in the form. After a database query, when the form is filled with a given record, the print action can be activated.
Depending on the front-end ergonomics, the visual result of disabling an action can be different. On desktop front-ends, the action views (buttons) are typically grayed, indicating that the action is there but cannot be triggered. On other front-ends such as some mobile devices, the action view might be hidden, for layout reasons (there is not much space on a mobile device screen).
BEFORE INPUT CALL DIALOG.setActionActive( "zoom", FALSE )
FUNCTION cust_dialog_setup(d) DEFINE d ui.Dialog DEFINE can_modify BOOLEAN LET can_modify = (cust_rec.is_new OR user_info.is_admin) CALL d.setActionActive("update", can_modify) CALL d.setActionActive("delete", can_modify) ... END FUNCTION
Some predefined dialog actions such as insert / append / delete of INPUT ARRAY are automatically enabled/disabled according to the context. For example, if the maximum number of rows (MAXCOUNT) is reached in an INPUT ARRAY, insert and append actions are disabled.
When the action activation depends on the focus being in a specific field, consider using the INFIELD clause of ON ACTION to automatically disable an action if the focus leaves the specified field.
DIALOG ATTRIBUTES(UNBUFFERED) DISPLAY ARRAY a_ord TO s_ord.* -- sub-dialog-level action ON ACTION check_row ... END DISPLAY ... INPUT BY NAME rec.* ... ON CHANGE consolidation -- Must use sub-dialog name to identify the check_row action: CALL DIALOG.setActionActive( "s_ord.check_row", FALSE ) ... END INPUT END DIALOG