Hi,
I found a problem related to "Gadget" and attached source code
is a simple example to reproduce it.
When "gpb2" is used, Lesstif makes warnings as the below and
freeze for a while. "gpb1" does not cause the same problem.
"gpb1": call PushButton
"gpb2": call PushButtonGadget
---------- warnings ------------
Warning:
Name: pl
Class: XmRowColumn
Can't grab the keyboard.
Warning:
Name: pl
Class: XmRowColumn
Can't grab the pointer.
--------------------------------
It doesn't seems that Lesstif updates the translation table correctly
when using "Gadget". Actually, translation routine for "RowColumn" is
called when any buttons on Dialog is pushed.
Temporary workaround is the below. But I am not sure it ensures the
correct behavior for all of case.
-----------------------------------------------------------------------
diff -uNr lesstif-0.90.0/lib/Xm/RowColumn.c lesstif-0.90.0-i18n/lib/Xm/RowColumn.c
--- lesstif-0.90.0/lib/Xm/RowColumn.c Sun Mar 12 18:43:05 2000
+++ lesstif-0.90.0-i18n/lib/Xm/RowColumn.c Sun Apr 30 14:47:19 2000
@@ -3102,6 +3102,8 @@
MGR_HighlightedWidget(w) = gadget;
_XmDispatchGadgetInput((Widget)gadget, event, XmARM_EVENT);
+ _XmMenuFocus(w, XmMENU_FOCUS_SAVE, CurrentTime);
+ return;
}
}
DEBUGOUT(XdbDebug("MENU", w, "_XmMenuBtnDown - %i %s\n",
@@ -3198,6 +3200,7 @@
DEBUGOUT(XdbDebug2(__FILE__, w, gadget, "MenuBtnUp(in gadget)\n"));
_XmDispatchGadgetInput((Widget)gadget, event, XmACTIVATE_EVENT);
+ return;
}
DEBUGOUT(XdbDebug("MENU", w, "_XmMenuBtnUp - %s %s posted\n",
_XmGetInDragMode(w) ? "dragging" : "not-dragging",
-------------------------------------------------------------------------
ENVIRONMENT
lesstif: 0.90.0
OS : Linux(RedHat6.0)
X : XFree86-3.3.3.1
Thanks.
--
Kazuyuki Funada
#include <Xm/XmAll.h>
#include <Xm/XmP.h>
Widget toplevel;
void MenuCallback(Widget w,XtPointer client_data,XtPointer call_data)
{
MakeDialog();
}
int main(int argc, char **argv)
{
Widget fm, mb, cb, pl, gpb[2];
Arg args[1];
toplevel = XtInitialize(argv[0], "Pulldown", NULL, 0, &argc, argv);
fm = XmCreateForm(toplevel, "fm", NULL, 0);
XtManageChild(fm);
mb = XmCreateMenuBar(fm, "mb", NULL, 0);
XtManageChild(mb);
cb = XmCreateCascadeButton(mb, "cb", NULL, 0);
XtManageChild(cb);
pl = XmCreatePulldownMenu(mb, "pl", NULL, 0);
XtSetArg(args[0], XmNsubMenuId, pl);
XtSetValues(cb, args, 1);
gpb[0] = XmCreatePushButton(pl, "gpb1", NULL, 0);
XtAddCallback(gpb[0], XmNactivateCallback, MenuCallback, NULL);
gpb[1] = XmCreatePushButtonGadget(pl, "gpb2", NULL, 0);
XtAddCallback(gpb[1], XmNactivateCallback, MenuCallback, NULL);
XtManageChildren(gpb, 2);
XtRealizeWidget(toplevel);
XtMainLoop();
}
int MakeDialog()
{
Widget dlg;
XEvent event;
dlg=XmCreateQuestionDialog(toplevel, "messagebox", NULL, 0);
XtManageChild(dlg);
while (XtIsManaged(dlg)) {
XtNextEvent(&event);
XtDispatchEvent(&event);
}
XtDestroyWidget(XtParent(dlg));
return 0;
}