Setting key labels

Labels can be defined to decorate buttons controlled by ON KEY/COMMAND KEY action handlers.

Syntax

Key label configuration can take place at different levels.

  1. key-name is the name of the key.
  2. label is the text to be displayed in the default action view (button).

Usage

When using the graphical mode, ON KEY and COMMAND KEY action handlers in dialogs can be shown as form buttons when a label text is defined for the key. By defining a label for a key, the runtime system will automatically show a default button for the key action.

Important: Key label configuration is provided for backward compatibility. Consider using action configuration in new programs.

In the next example, the function key F10 is used to show a detail window in this interactive dialog:

INPUT BY NAME myrecord.*
  ON KEY (F10)
    CALL ShowDetail()
END INPUT

By default, if you do not specify a label, no default action button is displayed for a function key or control key.

If the text provided for the key label is empty or null, the default action button will not be displayed.

Table 1. Key names recognized by the runtime system
Key Name Description
f1 to f255 Function keys.
control-a to control-z Control keys.
accept Predefined dialog validation action.
interrupt Predefined dialog cancellation action. The action name is cancel, not interrupt.
insert Predefined INPUT ARRAY dialog row insertion action.
append Predefined INPUT ARRAY dialog row addition action.
delete Predefined INPUT ARRAY dialog row deletion action.
help Predefined help action.

Key labels can be defined at different levels. The order of precedence for key label definition is the following:

  1. The label defined with the KEY attribute of the form field.
  2. The label defined for the current dialog, using the FGL_DIALOG_SETKEYLABEL function.
  3. The label defined in the KEYS section of the form specification file.
  4. The label defined as default for a program, using the FGL_SETKEYLABEL function.
  5. The label defined in the FGLPROFILE configuration file (key.key-name.text entries).

In Genero, you typically define action labels with action attributes. However, if key labels are defined, they will overwrite the text defined in action attributes for the corresponding key action. In BDS 3.xx versions, default key labels are defined in FGLDIR/etc/fglprofile. These defaults have been commented out in Genero to have action attribute text applied (In Genero, by default, fgl_getkeylabel() returns NULL for all keys). If you want to get the same default key labels as in BDS 3.xx, uncomment the key.* lines in FGLDIR/etc/fglprofile.

You can query the label defined at the program level with the FGL_GETKEYLABEL function and, for the current interactive instruction, with the FGL_DIALOG_GETKEYLABEL function.