Name
XtAppAddActions — declare an action table and register it with the Resource Manager.
Synopsis
void XtAppAddActions(app_context, actions, num_actions)
XtAppContext app_context;
XtActionList actions;
Cardinal num_actions;
Arguments
app_context
Specifies the application context.
actionsSpecifies the action table to register.
num_argsSpecifies the number of entries in this action table.
Description
All widget class records contain an action table. In addition, using XtAppAddActions, an application can register its own action tables with the Resource Manager. An action table consists of a list of string names (which can be used in translation tables to associate an action with one or more events) and corresponding function pointers. The function pointer is of type XtActionProc.
By convention, the string and the function name are identical except that the function name begins with an upper-case letter, as in the example:
static XtActionsRec two_quits[] = {
{"confirm", Confirm},
{"quit", Quit},
},
This mapping from strings to function pointers is necessary to allow translation tables to be specified in resource files, which are made up entirely of strings.
For example, the Command widget has procedures to take the following actions:
•Set the appearance of the Command widget to indicate it is activated when a pointer button has been pressed in it.
•Unset the button back to its normal mode.
•Highlight the button borders when the pointer enters the Command widget.
•Unhighlight the button borders when the pointer leaves.
•Notify any callbacks that the button has been activated.
The action table for the Command widget class makes these functions available to translation tables written for Command or any subclass:
XtActionsRec actionTable[] = {
{"Set",Set},
{"Unset",Unset},
{"Highlight",Highlight},
{"Unhighlight",Unhighlight}
{"Notify",Notify},
};
The actions specified in a translation can be registered before or after the translation table is parsed.
The items in an action list registered with XtAddActions are registered globally for the entire application. By contrast, the action list specified in a widget class structure is local--only translations specified by the widget itself can access local actions. However, a widget’s local translation can access global actions, if there is no local action of the same name.
If an application registers more than one global action with the same name, the most recently registered action is used. The Intrinsics register an action table for XtMenuPopup and XtMenuPopdown as part of XtCreateApplicationContext.
The Core class structure holds a list of translations and actions. Compare XtParseTranslationTable. Chapter 7, Events, Translations, and Accelerators, in Volume Four, X Toolkit Intrinsics Programming Manual, contains general discussion and examples.
If more than one action is registered with the same name, the most recently registered action is used. If duplicate actions exist in an action table, the first is used. The Intrinsics register an action table for actions called MenuPopup and MenuPopdown as part of X Toolkit initialization.