Implementing the close action

The close action is a predefined action dedicated to close graphical windows (for example, with the X cross button).

In graphical applications, windows can be closed by the user, for example by pressing Alt+F4 or by clicking the cross button in the upper-left corner of the window. A predefined action is dedicated to this specific event, named "close".

When the end user closes a graphical window, the program gets a close action.

Note that the default action view (i.e. button in the action frame) of the close action is hidden.

The close action in DIALOG 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 form input 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 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 in MENU dialogs

When an ON ACTION close handler is defined in a MENU statement, the handler code will be executed if the close action is fired.

If no explicit ON ACTION close action handler is defined, the code of the COMMAND KEY(INTERRUPT) or ON ACTION cancel will be executed, if defined. if neither COMMAND KEY(INTERRUPT) nor ON ACTION cancel are defined, nothing happens and the program stays in the MENU instruction. Regarding the close action, the value of INT_FLAG is undefined in a MENU instruction.

The close action on mobile devices

When displaying on a mobile device, the close action is rendered differently according to the type of mobile platform:
  • On Androidâ„¢, the close action is mapped to the [Back] button (it is not rendered in the action panel)
  • On iOS, there is no [Back] button concept and the close action is rendered as a regular action.

For more details, see Rendering default action views on mobile.

Example

You typically implement a close action handler to open a confirmation dialog box as in 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