Name
XtAddActions — register an action table with the Translation Manager.
Synopsis
void XtAddActions(actions, num_actions)
XtActionList actions;
Cardinal num_actions;
Arguments
actionsSpecifies the action table to register.
num_actions
Specifies the number of entries in this action table.
Description
XtAddActions has been superseded by XtAppAddActions. Using XtAddActions, an application can register its own action tables with the Translation 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 Intrinsics reserve all action names and parameters starting with the characters Xt for future standard enhancements. Users, applications and widgets should not declare action names or pass parameters starting with these characters except to invoke specified built-in Intrinsics functions.
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.
Action procedures should not assume that the widget in which they are invoked is realized; an accelerator specification can cause an action procedure to be called for a widget which does not yet have a window. Widget writers should also note which of a widget’s callback lists are invoked from action procedures and should warn clients not to assume the widget is realized in those callbacks.
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. Chapter 7, Events, Translations, and Accelerators, in Volume Four, X Toolkit Intrinsics Programming Manual, contains general discussion and examples.
Structures
The XtActionList is a pointer to an XtActionsRec, defined as follows in <X11/Intrinsic.h>:
typedef _XtActionsRec ∗XtActionList;
typedef struct _XtActionsRec {
String string;
XtActionProc proc;
} XtActionsRec;
The string field is the name that you use in translation tables to access the procedure. The proc field is a pointer to a procedure that implements the functionality.
The form of an XtActionProc is described in XtActionProc (2).
See Also
XtAppAddActions(1), XtParseTranslationTable(1), MenuPopdown(1), MenuPopup(1),
XtActionProc(2),
Core(3).