Defining keyboard accelerators for actions

Keyboard accelerators keys are attributes defining the keyboard shortcuts for actions.

Keyboard accelerators can be defined at several levels (global action defaults, form file action defaults, dialog instructions).

For example, in a .per form file ACTION DEFAULTS section:
ACTION DEFAULTS
   ACTION print (TEXT="Print", ACCELERATOR=Control-P)
END
Note: Up to four accelerator keys can be defined for the same action in action defaults. However, as a general pattern, define only one accelerator per action.

If no accelerators are defined for an action, the runtime system sets default accelerators for predefined actions, depending on the user interface mode. For example, the accept action will get the Return and Enter keys in GUI mode, but gets the Escape key in TUI mode.

If a user-defined action is defined with an accelerator that would normally be used for a predefined action, the runtime system does not set that accelerator for the predefined action. For example (in GUI mode), if you define an ON ACTION quit with an action default using the accelerator "Escape", the "cancel" predefined action will not get the "Escape" default accelerator. In this case, user settings take precedence over defaults.

Note: Text edition and navigation keys such as [Home] and [End] are usually local to the widget. Depending on the context, such common keys might be eaten by the graphical widget and will not invoke the action configured with the corresponding accelerator. For example, even if the "firstrow" action defines the Home accelerator, when using an INPUT ARRAY, the [Home] key will jump to the beginning of the edit field, not the first row of the list.

When using the ON ACTION clause in a dialog instruction, action accelerators are used in both GUI and TUI mode. However, for backward compatibility, this is not done in TUI mode when using the ON KEY clause.

The traditional ON KEY clause in a dialog like INPUT implicitly defines the acceleratorName attribute for the action, and the corresponding action default accelerator will be ignored. For example, when you define an ON KEY(F10) block, the first accelerator will be "F10", even if an action default defines an accelerator "F5" for the action "F10". However, you can set other accelerators with the acceleratorName2, acceleratorName3 and acceleratorName4 attributes in action defaults.

Important: In TUI mode, actions created with ON KEY do not get accelerators of action defaults; only actions defined with ON ACTION will get accelerators of action defaults.

In menus, the behavior is a bit different, see the COMMAND and COMMAND KEY clause of MENU.

If you want to force an action to have no accelerator, you can use none as the accelerator name.