Configuring actions

Action attributes related to decoration, keyboard shortcuts and behavior can be defined with action attributes.

Action attributes define attributes for actions, including decoration such as text, icon, comment, as well as keyboard accelerator (ctrl-?, function keys), and also semantics such as current field validation control when an action is fired.

The action attributes can be defined at different levels, through action defaults, form item attributes and action handler attributes:

  1. Common action attributes can be centralized in a global action defaults file with the .4ad extension,
  2. Form-specific action attributes can be defined in the ACTION DEFAULTS section of a form definition file,
  3. Dialog-specific action attributes can be defined in programs with the ATTRIBUTES() clause of ON ACTION handlers.
  4. Form-item specific action view attributes (decoration only) can be defined directly at the item level (labels, icons, comments).

Action attributes do not only define action view decoration: It is possible to define the semantics of an action, for example by using the VALIDATE action default attribute. Functional attributes take effect for a given action when the dialog implementing the action handler becomes active.

Action attributes are particularly important to render the default action view (when there is no explicit action view defined in the form). This is typically the case when not form is associated to the dialog.

Action attributes can be defined with action defaults: Common action defaults are defined in a global action defaults (.4ad) file, while form specific actions are define withing the ACTION DEFAULTS section of form files.

If a dialog is not attached to a specific form such as an independent MENU, define the action attributes with the ATTRIBUTES clause on ON ACTION handlers, to render the default view and configure the action semantics. Attributes defined by ON ACTION action-name ATTRIBUTES() will only be applied to the default action view: The elements in the forms do not get decoration attributes defined by dialog action handlers.

The final decoration and functional attribute values are set in this order of precedence:

  1. The attribute defined in the action view element definition itself (local form element decoration).
  2. The attribute defined in the ATTRIBUTES clause of an ON ACTION handler.
  3. The attribute defined for the action in the ACTION DEFAULTS section of the current form.
  4. The attribute defined for the action in the global action defaults file (.4ad).
Note that the syntax to define action attributes depends on the context where the action attributes are defined:

Example

Consider the following parts of code related to the same action definition, namely "print":

1. A BUTTON item defined in the form specification file:

ATTRIBUTES
 BUTTON b1: print, TEXT="Print item";
END

2. A dialog instruction with code defining the ON ACTION handler with an ATTRIBUTES clause:

DIALOG ...
   ...
   ON ACTION print
      ATTRIBUTES( ROWBOUND, IMAGE = "printer_2" )
      ...

3. The form ACTION DEFAULTS section defining:

form.per:
ACTION DEFAULTS
  ACTION print (IMAGE="printer_1",
                COMMENT="Print the order",
                ACCELERATORNAME=Control-P,
                CONTEXTMENU=NO)
END

4. A global .4ad action defaults file defining:

<ActionDefaultList>
  <ActionDefault name="print" text="Print" image="smiley" />
</ActionDefaultList>

When the dialog executes, the "print" action will get the following functional attributes:

The form button (i.e. the action view) will get the following decoration attribute values: