Dialog actions / Configuring actions |
Action defaults allow to define default attributes for common action. These defaults can be overwritten with form item attributes, or with dialog action handler attributes (only for default action views).
Centralize action attributes with action defaults, to avoid specifying them in all the source files that define the same action view and action handler. For example, you can specify the default text, image and keyboard accelerator for elements like push buttons, toolbar items, topmenu options.
Common action defaults are typically defined in a global action defaults (.4ad) file, while form specific actions are configured with form action defaults in the ACTION DEFAULTS section of the .per form specification file.
Global action defaults are defined in an XML file with the 4ad extension. By default, the runtime system searches for a file named default.4ad in the current directory. If the file does not exist, it searches in the directories defined by the FGLRESOURCEPATH (or DBPATH) environment variable. If no file was found using the environment variable(s), standard action default settings are loaded from the FGLDIR/lib/default.4ad file.
If needed, override the default search by loading a specific global action defaults file with the ui.Interface.loadActionDefaults() method.
<ActionDefaultList> <ActionDefault name="yes" text="Yes"> <LStr text="common.yes"/> </ActionDefault> ...
ACTION DEFAULTS ACTION print (TEXT="Print", IMAGE="printer", COMMENT="Print the current record", ACCELERATOR=CONTROL-P) END
Form action defaults can also be defined in a .4ad file to be loaded dynamically with the ui.Form.loadActionDefaults() method. This method is typically used in form initializers to decorate several application forms without defining an ACTION DEFAULTS section in each .per file.
ACTION print (TEXT=%"common.print")
Decoration attributes (like TEXT, IMAGE) of an action view will automatically be set with the value defined in the action defaults to all new action views of a new created form, if there is no explicitly value specified in the element definition for that attribute. Decoration action default attributes are applied only once, to newly created form elements: Dynamic changes are not reapplied to action views. For example, if you first load a toolbar, then you load a global action defaults file, the attributes of the toolbar items will not be updated with the last loaded action defaults. If you dynamically create action views (like TopMenu or ToolBar), the action defaults are not applied, so you must set all decoration attributes by hand.
The action default attributes to be applied are selected according to name of the action. In some situations, the action view can be bound to an action handler by specifying a sub-dialog and/or field name prefix. For those views, the action defaults defined with the corresponding action name will be used to set the attributes with the default values. In other words, the prefix will be ignored. For example, if an action view is defined with the name custlist.append, it will get the action defaults defined for the append action.
Functional attributes (like VALIDATE, ACCELERATOR) can only be defined in action defaults, or in ON ACTION dialog action handlers with the ATTRIBUTES clause. Functional attributes take effect for a given action when the dialog becomes active.