All Motif widgets descend from Core. Therefore, all Motif widgets define keyboard translations through the following two fields of the Core class record:
The tm_table field, which holds the name of a string. This string contains information that maps event to action routine names.
The actions field, which holds the name of an array that maps the action routine names in the translation string to the action methods defined by your widget.
For example, the ExmMenuButton widget provides the following string for its tm_table field:
static char defaultTranslations[] = "<EnterWindow>: MenuButtonEnter()\n\ <LeaveWindow>: MenuButtonLeave()\n\ <BtnDown>: BtnDown()\n\ <BtnUp>: BtnUp()\n\ :<Key>osfActivate: ArmAndActivate()\n\ :<Key>osfCancel: MenuEscape()\n\ :<Key>osfHelp: MenuButtonHelp()\n\ ~s ~m ~a <Key>Return: ArmAndActivate()\n\ ~s ~m ~a <Key>space: ArmAndActivate()";
and the following array for the actions field:
static XtActionsRec Actions[] = { {"ArmAndActivate", ArmAndActivate}, {"BtnDown", BtnDown}, {"BtnUp", BtnUp}, {"MenuButtonEnter", MenuButtonEnter}, {"MenuButtonLeave", MenuButtonLeave}, {"MenuButtonHelp", MenuButtonHelp} };
In addition to the two fields of CoreClassPart, both PrimitiveClassPart and ManagerClassPart provide an additional field named translations. You can set the translations field to one of the following:
Most standard Motif widgets set the additional translation field either to NULL or to XtInheritTranslations. If you are subclassing the XmPrimitive widget and specify XtInheritTranslations, you will inherit the following actions:
<Unmap>: PrimitiveUnmap()\n\ <FocusIn>: PrimitiveFocusIn()\n\ <FocusOut>: PrimitiveFocusOut()\n\ :<Key>osfActivate: PrimitiveParentActivate()\n\ :<Key>osfCancel: PrimitiveParentCancel()\n\ :<Key>osfBeginLine: PrimitiveTraverseHome()\n\ :<Key>osfUp: PrimitiveTraverseUp()\n\ :<Key>osfDown: PrimitiveTraverseDown()\n\ :<Key>osfLeft: PrimitiveTraverseLeft()\n\ :<Key>osfRight: PrimitiveTraverseRight()\n\ ~s ~m ~a <Key>Return: PrimitiveParentActivate()\n\ s ~m ~a <Key>Tab: PrimitivePrevTabGroup()\n\ ~m ~a <Key>Tab: PrimitiveNextTabGroup()";
(All these actions are documented in the reference page for XmPrimitive; see the Motif Programmer's Reference for details.) By specifying XtInheritTranslations in a subclass of XmPrimitive, your widget will automatically inherit the standard keyboard traversal translations for primitive widgets.
If you are subclassing the XmManager widget and specify XtInheritTranslations, your subclass will inherit the following actions:
<EnterWindow>: ManagerEnter()\n\ <LeaveWindow>: ManagerLeave()\n\ <FocusOut>: ManagerFocusOut()\n\ <FocusIn>: ManagerFocusIn()\n\ :<Key>osfBeginLine: ManagerGadgetTraverseHome()\n\ :<Key>osfUp: ManagerGadgetTraverseUp()\n\ :<Key>osfDown: ManagerGadgetTraverseDown()\n\ :<Key>osfLeft: ManagerGadgetTraverseLeft()\n\ :<Key>osfRight: ManagerGadgetTraverseRight()\n\ s ~m ~a <Key>Tab: ManagerGadgetPrevTabGroup()\n\ ~m ~a <Key>Tab: ManagerGadgetNextTabGroup()";
(All these actions are documented in the reference page for XmManager; see the Motif Programmer's Reference for details.)