2.18. Translation Tables   

All widget instance records contain a translation table, which is a resource with a default value specified elsewhere in the class record. A translation table specifies what action procedures are invoked for an event or a sequence of events. A translation table is a string containing a list of translations from an event sequence into one or more action procedure calls. The translations are separated from one another by newline characters (ASCII LF). The complete syntax of translation tables is specified in Appendix B.

As an example, the default behavior of Pushbutton is

Highlight on enter window.

Unhighlight on exit window.

Invert on left button down.

Call callbacks and reinvert on left button up.

The following illustrates Pushbutton's default translation table:

static String defaultTranslations =
<Btn1Up>: Notify() Unset()";
The tm_table field of the CoreClassPart should be filled in at class initialization time with the string containing the class's default translations. If a class wants to inherit its superclass's translations, it can store the special value XtInheritTranslations into tm_table. In Core's class part initialization procedure, the Intrinsics compile this translation table into an efficient internal form. Then, at widget creation time, this default translation table is combined with the XtNtranslations and XtNbaseTranslations resources.

The resource conversion mechanism automatically compiles string translation tables that are specified in the resource database. If a client uses translation tables that are not retrieved via a resource conversion, it must compile them itself using XtParseTranslationTable.

The Intrinsics use the compiled form of the translation table to register the necessary events with the event manager. Widgets need do nothing other than specify the action and translation tables for events to be processed by the translation manager.

2.18.1. Event Sequences   

An event sequence is a comma-separated list of X event descriptions that describes a specific sequence of X events to map to a set of program actions. Each X event description consists of three parts: The X event type, a prefix consisting of the X modifier bits, and an event-specific suffix.

Various abbreviations are supported to make translation tables easier to read. The events must match incoming events in left-to-right order to trigger the action sequence.

2.18.2. Action Sequences   

Action sequences specify what program or widget actions to take in response to incoming X events. An action sequence consists of space-separated action procedure call specifications. Each action procedure call consists of the name of an action procedure and a parenthesized list of zero or more comma- separated string parameters to pass to that procedure. The actions are invoked in left-to-right order as specified in the action sequence.

2.18.3. Multi-click Time   

Translation table entries may specify actions that are taken when two or more identical events occur consecutively within a short time interval, called the multi-click time. The multi-click time value may be specified as an application resource with name ``multiClickTime'' and class ``MultiClickTime'' and may also be modified dynamically by the application. The multi-click time is unique for each Display value and is retrieved from the resource database by XtDisplayInitialize. If no value is specified, the initial value is 200 milliseconds.

To set the multi-click time dynamically, use XtSetMultiClickTime.

void XtSetMultiClickTime(display, time)
Display *display;
int time;
display Specifies the display connection.
time Specifies the multi-click time in milliseconds.
XtSetMultiClickTime sets the time interval used by the translation manager to determine when multiple events are interpreted as a repeated event. When a repeat count is specified in a translation entry, the interval between the timestamps in each pair of repeated events (e.g., between two ButtonPress events) must be less than the multi-click time in order for the translation actions to be taken.

To read the multi-click time, use XtGetMultiClickTime.

int XtGetMultiClickTime(display)
Display *display;
display Specifies the display connection.
XtGetMultiClickTime returns the time in milliseconds that the translation manager uses to determine if multiple events are to be interpreted as a repeated event for purposes of matching a translation entry containing a repeat count.