Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!emory!stiatl!gtl From: gtl@stiatl.UUCP (George Li) Newsgroups: comp.windows.x Subject: Accelerators Message-ID: <8006@stiatl.UUCP> Date: 4 Dec 89 21:14:38 GMT Organization: Sales Technologies Inc., "The Little Shop of Horrors..." Lines: 97 I'm having problems defining accelerators for widgets and getting the action procedures to execute. I have been able to define accelerators whose procedure name strings are defined by the particular widget class. For example, "H: set() notify() unset()" is a valid accelerator for a command widget. However, if I define my own action procedure and reference it in an accelerator as in "H: mutilate()", the installed accelerator has no effect (the procedure associated with the mutilate action isn't called). I've added the action (trying both XtAddAction() and XtAppAddAction()) with no success. Since an accelerator is just a translation table and you can define your own action procedures for translation tables, shouldn't I be able to define my own action procedures for accelerators? I'm using X11R3 (Athena widgets) on a Sun 386i with 4.0.2. A small sample below: /******************************************************************/ #include #include "Intrinsic.h" #include "StringDefs.h" #include "Command.h" #include "Desk.h" Widget toplevel; Widget desk; Widget button1; Widget button2; extern void helpproc(); main (argc, argv) int argc; char **argv; { int n; Arg args[20]; static Arg deskargs[] = { {XtNwidth,(XtArgVal)600}, {XtNheight,(XtArgVal)400}, }; /**********************************************************/ static XtActionsRec actionsTable[] = { {"help_action",helpproc} }; static char defaultAccelerators[]="#override\n L: help_action()"; /************************************************************/ toplevel = XtInitialize(argv[0], "test", NULL, 0, &argc, argv); desk = XtCreateManagedWidget("desk", deskWidgetClass, toplevel, deskargs, XtNumber(deskargs)); n = 0; XtSetArg(args[n], XtNwidth, 70); n++; XtSetArg(args[n], XtNheight, 20); n++; XtSetArg(args[n], XtNx, 100); n++; XtSetArg(args[n], XtNy, 280); n++; XtSetArg(args[n],XtNaccelerators,XtParseAcceleratorTable(defaultAccelerators));n++; button1=XtCreateWidget("button1",commandWidgetClass,desk,args,n); n=0; XtSetArg(args[n], XtNwidth, 70); n++; XtSetArg(args[n], XtNheight, 20); n++; XtSetArg(args[n], XtNx, 300); n++; XtSetArg(args[n], XtNy, 280); n++; button2=XtCreateWidget("button2",commandWidgetClass,desk,args,n); XtAddActions(actionsTable,XtNumber(actionsTable)); XtInstallAccelerators(button2,button1); XtManageChild(button1); XtManageChild(button2); XtRealizeWidget(toplevel); XtMainLoop(); } void helpproc(widget, xev, params, num_params) Widget widget; XEvent *xev; String *params; Cardinal *num_params; { printf("helpproc\n"); } -- George Li gatech!stiatl!gtl Sales Technologies, Inc 3399 Peachtree Rd, NE Atlanta, GA 30306