nazgul@alfalfa.com (Kee Hinckley) (03/11/91)
The following code installs accelerators some of the time. I can't for the
life of me figure out why it doesn't do it all the time. Furthermore, the
accelerator won't work unless the focus is set to a widget. I tried doing
gadgets, but then we died deep in Motif.
I don't know why this works when it does, or why it doesn't work when it
doesn't. I'd appreciate suggestions concerning either.
Set the accelerator resource on a widget, then call this. Note that the
order of the arguments is the opposite of XtInstallAccelerators (I use C++
and default the shell argument to NULL). Just call this with either NULL
or your toplevel shell. Then explore.
void OmXInstallAccelerators(Widget widget, Widget shell) {
Arg args[2];
Cardinal nkids, i;
Widget *kids;
if (!shell) {
for (shell = widget; shell && !XtIsShell(shell); shell = XtParent(shell)
);
if (!shell) return;
}
if (!XtIsWidget(shell)) return;
XtInstallAccelerators(shell, widget);
nkids = 0;
XtSetArg(args[0], XmNchildren, &kids);
XtSetArg(args[1], XmNnumChildren, &nkids);
XtGetValues(shell, args, 2);
for (i = 0; i < nkids; ++i) OmXInstallAccelerators(widget, kids[i]);
}
Alfalfa Software, Inc. | Poste: The EMail for Unix
nazgul@alfalfa.com | Send Anything... Anywhere
617/646-7703 (voice/fax) | info@alfalfa.com
I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.