[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page
Top Document: Motif FAQ (Part 6 of 9)
Previous Document: 200) How can I determine which widget has keyboard focus?
Next Document: 202) How can I have a modal dialog which has to be answered before
-
Search the FAQ Archives
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page
Top Document: Motif FAQ (Part 6 of 9)
Previous Document: 200) How can I determine which widget has keyboard focus?
Next Document: 202) How can I have a modal dialog which has to be answered before
201) How can I direct the keyboard input to a particular widget?
Answer: In Motif 1.1 call XmProcessTraversal(target, XmTRAVERSE_CURRENT). The
widget (and all of its ancestors) does need to be realized BEFORE you call
this. Otherwise it has no effect. XmProcessTraversal is reported to have many
bugs, so it may not work right. A common occurrence is that it doesn't move
to the widget, but if you call XmProcessTraversal *twice* in a row, it will.
If you can't get it to work, try this from Kee Hinckley:
// This insane sequence is as follows:
// On manage set up a focus callback
// On focus callback set up a timer (and get rid of focus callback!)
// On timer set the focus (which only works if the parent
// has the focus,
// which is why we went through all of this garbage)
// There may be a better way, but I haven't time to try it now.
//
static void focusTO(void *data, XtIntervalId *) {
XmProcessTraversal((Widget) data, XmTRAVERSE_CURRENT);
}
static void focusCB(Widget w, XtPointer data, XtPointer) {
XtRemoveCallback(w, XmNfocusCallback, focusCB, data);
XtAppAddTimeOut(XtWidgetToApplicationContext(w), 0, focusTO, data);
}
void OmXSetFocus(Widget parent, Widget w) {
XtAddCallback(parent, XmNfocusCallback, focusCB, w);
}
In Motif 1.0 call the undocumented _XmGrabTheFocus(target).
Do not use the X or Xt calls such as XtSetKeyboardFocus since this bypasses
the Motif traversal layer and can cause it to get confused. This can lead to
odd keyboard behaviour elsewhere in your application.
Top Document: Motif FAQ (Part 6 of 9)
Previous Document: 200) How can I determine which widget has keyboard focus?
Next Document: 202) How can I have a modal dialog which has to be answered before
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page
[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
Send corrections/additions to the FAQ Maintainer:
kenton@rahul.net (Ken Lee)
Last Update October 22 2009 @ 05:27 AM