John.Hagerman@rx7.ece.cmu.EDU, at.rx7@rx7.ece.cmu.EDU (02/26/90)
I'm having trouble getting accelerators to work. What's wrong with the following code? The intent is to have a Return keypress in the dialog's `value' widget cause a set()notify()unset() action sequence in the dialog's `show' widget. I'm using the R3 Athena widgets on a DS 3100 running Ultrix. Thanks for any help - John hagerman@ece.cmu.edu #include <stdio.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Command.h> #include <X11/Dialog.h> #include <X11/Shell.h> Widget Dialog; Arg DialogArgs[] = { { XtNlabel, (XtArgVal) "label"}, { XtNvalue, (XtArgVal) "value"}, }; ShowCallback(w, client_data, call_data) Widget w; caddr_t client_data, call_data; { printf("%s\n", XtDialogGetValueString(Dialog)); } main(argc, argv) int argc; char **argv; { Display *dsp; XtAppContext ac; Widget top, cmd, val; XtAccelerators acc; Arg arg[1]; XtToolkitInitialize(); ac = XtCreateApplicationContext(); dsp = XtOpenDisplay(ac, 0, 0, "accel", 0, 0, &argc, argv); top = XtAppCreateShell(0, "top", applicationShellWidgetClass, dsp, 0, 0); Dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, top, DialogArgs, XtNumber(DialogArgs)); cmd = XtCreateManagedWidget("show", commandWidgetClass, Dialog, 0, 0); XtAddCallback(cmd, XtNcallback, ShowCallback, 0); val = XtNameToWidget(Dialog, "value"); acc = XtParseAcceleratorTable("<Key>Return:set()notify()unset()"); XtSetArg(arg[0], XtNaccelerators, (XtArgVal) acc); XtSetValues(cmd, arg, 1); XtInstallAccelerators(val, cmd); XtRealizeWidget(top); XtAppMainLoop(ac); }
converse@EXPO.LCS.MIT.EDU (Donna Converse) (02/27/90)
> I'm having trouble getting accelerators to work. What's wrong with > the following code? The intent is to have a Return keypress in the > dialog's `value' widget cause a set()notify()unset() action sequence > in the dialog's `show' widget. I'm using the R3 Athena widgets on a > DS 3100 running Ultrix. Section 10.4 of the Intrinsics documentation states that the default directive is #augment, "which means that the accelerator translations have lower priority than the destination translations." Because the Dialog's input area widget, the "value" widget, is an AsciiText widget, it has the default translations of the Text widget, including a translation for the return key. To specify that your accelerator translation take higher priority than the Text widget's translation, use the #override directive: acc = XtParseAcceleratorTable("#override<Key>Return:set()notify()unset()"); Donna Converse converse@expo.lcs.mit.edu
gabe@hpcvlx.cv.hp.com (Gabe Begeddov) (02/27/90)
/ hpcvlx:comp.windows.x / John.Hagerman@rx7.ece.cmu.EDU, at.rx7@rx7.ece.cmu.EDU / 11:27 am Feb 25, 1990 /
I'm having trouble getting accelerators to work. What's wrong with
the following code? The intent is to have a Return keypress in the
dialog's `value' widget cause a set()notify()unset() action sequence
in the dialog's `show' widget. I'm using the R3 Athena widgets on a
DS 3100 running Ultrix.
Thanks for any help - John
hagerman@ece.cmu.edu
acc = XtParseAcceleratorTable("<Key>Return:set()notify()unset()");
XtSetArg(arg[0], XtNaccelerators, (XtArgVal) acc);
XtSetValues(cmd, arg, 1);
XtInstallAccelerators(val, cmd);
XtRealizeWidget(top);
XtAppMainLoop(ac);
}
----------
The problem seems to be the merge mode used.
XtInstallAccellerators will merge the accelerators using
augment semantics unless there is an explicit "#override"
directive in the accelerators string. Try:
acc = XtParseAcceleratorTable("#override <Key>Return:set()notify()unset()");
Gabe Beged-Dov
Interface Technology Operation
Hewlett-Packard
---------------
"Home of the Motif Lite Widget-Brewery"