Implementing the close
action
The close
action is a predefined action dedicated to close graphical
windows (for example, with the X cross button).
Purpose of the close
action
In graphical applications, windows can be closed by the user, for example by pressing Alt+F4 or by clicking the X cross button in the upper-right corner of the window.

Genero BDL has a predefined action named "close
" dedicated to this specific
window closing event.
When the end user closes a graphical window, the program gets a close action. It is then possible
to execute user code in an ON ACTION close
action handler, or leave the default
behavior.
The default action view of the
"close
" action is hidden.
The close
action in multiple dialogs
When executing a DIALOG
instruction, the close
action executes
the ON ACTION close
block, if defined. Otherwise, the close action is mapped to the
cancel action if an ON ACTION cancel
handler is defined.
If neither ON ACTION close
, nor ON ACTION cancel
are defined, nothing will happen if the user tries to close the window with the X
cross button or an ALT+F4
keystroke.
The int_flag
register will not
be set in the context of DIALOG
.
The close
action in singular dialogs
When an ON ACTION close
handler is defined in an INPUT
,
INPUT ARRAY
, CONSTRUCT
, DISPLAY ARRAY
or
PROMPT
interactive instruction, the handler code will be executed if the close
action is fired.
If no explicit ON ACTION close
handler is defined, the close
action acts the same as the cancel predefined action. So by default when the user clicks the X cross
button in a window, the interactive instruction stops and the int_flag
is set to 1.
If there is an explicit ON ACTION cancel
block defined,
int_flag
is set to 1 and the user code under ON ACTION cancel
will be executed.
If the CANCEL=FALSE
option is set, no cancel and no close
action will be created, and you must write an ON ACTION close
handler to proceed
with the close action. In this case, the int_flag
register will not be set when the
close
action is invoked.
The close action on mobile devices
When displaying on Androidâ„¢ and iOS mobile device, the
close
action can be bound to the "Back button". For more details, see The Back button
Example
You typically implement a close action handler to open a confirmation dialog box as in the following example:
INPUT BY NAME cust_rec.*
...
ON ACTION close
IF msg_box_yn("Are you sure you want to close this window?") == "y" THEN
EXIT INPUT
END IF
...
END INPUT