Summary:
See also: Dynamic User Interface, Predefined Actions, Action Defaults and MENU.
Action Defaults allows you to define default attributes for graphical objects associated with actions.
<ActionDefaultList>
<ActionDefault name="action-name" [ attribute=value
[...] ] />
[...]
</ActionDefaultList>
Action defaults are provided to centralize the decoration attributes and accelerator keys for action views (graphical objects associated with actions). It is strongly recommended that you centralize those decoration attributes to avoid specifying them in all the source files that define the same action view.
Each attribute of an action view element associated with an action will automatically be set to the value defined in the Action Defaults, if there is no value explicitly specified in the element definition for that attribute.
Action Defaults can be defined globally for the whole program or at the form level. Global Action Defaults are loaded from a default 4ad file or by using the ui.Interface.loadActionDefaults() method. Form Action Defaults can be specified in the form file or can be loaded with the ui.Form.loadActionDefaults() method.
For example, in most cases a 'print' action needs a text decoration "Print", with a printer icon image and a CONTROL-P accelerator key. Those attributes can be centralized in the Action Defaults. Some action views of the 'print' action may need specific attributes; for example, if the current form handles customer addresses, the comment attribute of a 'print' button might be "Print current customer information". In this case you can define Action Defaults at the form level, which have a higher priority as the global Action Defaults. Additionally, if some action views must have a different image in the same form, you can specify the image attribute in the definition of each element to overwrite the defaults. For example, the 'print' toolbar button might have a small image, while the 'print' button in the form might have a large one.
The final attribute values used for a graphical elements are set according to the following order:
The following code defines a BUTTON in the form specification file::
01
ATTRIBUTES02
BUTTON b1: print, TEXT="Do Print";03
END
if the form Action Defaults define:
<ActionDefaultList>
<ActionDefault name="print"
image="smiley" comment="Print orders" acceleratorName="control-p"
/>
</ActionDefaultList>
and the global Action Defaults define:
<ActionDefaultList>
<ActionDefault name="print" text="Print"
image="printer" />
</ActionDefaultList>
the button object will get the following final attribute values:
text = "Do Print"
image = "smiley"
comment = "Print order"
and the accelerator will be CONTROL-P.
The following attributes can be defined with Action Defaults:
Attribute | Description |
name = string | This attribute identifies the action. See also predefined action names. |
text = string | The default label to be displayed in action views (typically, the text of buttons). |
comment = string | The default help text for this action (typically, displayed as bubble help). |
image = string | The default image file to be displayed in the action view. |
acceleratorName = string | The default accelerator key that can trigger the action, as defined in Accelerators. |
acceleratorName2 = string | The second default accelerator key that can trigger the action, as defined in Accelerators. |
defaultView = string | Indicates if the front-end must show the default action
view (ring menu or action buttons). Values can be: - "yes" the default action view is always visible.- "no" the default action view is never visible.- "auto" the default action view is visible if no
other action view is explicitly defined, such as a Toolbar
button, Topmenu option, BUTTONEDIT
or BUTTON form item.The default is "auto" . |
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 this file does not exist, it searches in
the directories defined in the DBPATH
environment variable. If no file was found using DBPATH, standard action default
settings are loaded from the "FGLDIR/lib/default.4ad
"
file.
4ad
"
files.You can override the default search by loading a specific Action Defaults file
with the ui.Interface.loadActionDefaults() method.
This method accepts an absolute path with the "4ad
"
extension or a simple file name without the "4ad
"
extension. If you give a simple
file name, for example "mydefaults
", the runtime
system searches for the "mydefaults.4ad
" file in the current directory. If the file does not
exist, it searches in the directories defined in the
DBPATH environment variable.
Action Defaults can be defined at the form level. When action defaults are defined in the form file, action views get the attributes defined locally.
You can define form action defaults with the ACTION DEFAULTS section in the form specification file. If you want to use common action defaults in several forms, you can use the preprocessor include directive to integrate an external file.
You can also load Form Action Defaults dynamically
with the ui.Form.loadActionDefaults() method.
This method accepts an absolute path with the "4ad
"
extension or a simple file name without the "4ad
"
extension. If you give a simple
file name, for example "mydefaults
", the runtime
system searches for the "mydefaults.4ad
" file in the current directory. If the file does not
exist, it searches in the directories defined in the
DBPATH environment variable.
Some Action Defaults in XML format:
01
<ActionDefaultList>02
<ActionDefault name="print" text="Print" image="printer" comment="Print report" />03
<ActionDefault name="modify" text="Update" comment="Update the record" />04
<ActionDefault name="exit" text="Quit" image="byebye" comment="Exit the program" />05
</ActionDefaultList>
The program loading the action defaults file:
01
MAIN02
CALL ui.Interface.loadActionDefaults("mydefaults")03
END MAIN