home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!oceanroutes.ns.ca!deveau
- From: deveau@oceanroutes.ns.ca ("Terry J. Deveau")
- Newsgroups: comp.windows.x.motif
- Subject: Re: Ctrl<Key>q to quit
- Message-ID: <9208141853.AA28389@BU.EDU>
- Date: 14 Aug 92 18:53:09 GMT
- Sender: sklower@ucbvax.BERKELEY.EDU
- Distribution: inet
- Organization: Oceanroutes Canada Inc.
- Lines: 47
-
- > From: hoswell@tramp.colorado.edu
- >
- > > From: deveau@oceanroutes.ns.ca
- > >
- > > > From: hoswell@tramp.colorado.edu
- > >
- > > >I'm having a bit of a problem setting a simple default translation...
- > > >
- > > >All I want to do is have a Quit routine called when I hit Ctrl<Key>q.
- > > >
- > > >I've tried this:
- > > >
- > > >static XtActionsRec actionsTable[] = {
- > > > {"bye", Quit},
- > > >};
- > > >static char defaultTranslations[] = "Ctrl<Key>q: bye()";
- > >
- > > Have you considered using an XmAccelerator instead?
- > >
- >
- > uh, no - simply because I don't know how! I understand that, for instance,
- > I can have a 'Quit' button and have an 'Accelerator' associated with it...
- > Is it easy to set up?
-
- Yes it is easy to set up. See the XmNaccelerator and XmNacceleratorText
- resources of the XmPushbuttonGadget widget (as inherited from
- XmLabelGadget). Note that it only works if the push button is in a
- pulldown or popup menu pane (see FAQ-Motif, subject 59). The code
- below should give you the general idea:
-
- int n;
- Arg arg[10];
- XmString str, str2;
- Widget pushbutton, menuPane;
-
- n = 0;
- str = XmStringCreateLtoR ("Button Label", XmSTRING_DEFAULT_CHARSET);
- XtSetArg(arg[n], XmNlabelString, str); n++;
- XtSetArg(arg[n], XmNaccelerator, "Ctrl<Key>q: bye()"); n++;
- str2 = XmStringCreateLtoR (" (^Q)", XmSTRING_DEFAULT_CHARSET);
- XtSetArg(arg[n], XmNacceleratorText, str2); n++;
-
- pushbutton = XmCreatePushbuttonGadget(menuPane,"pushbutton", arg, n);
- XmStringFree (str);
- XmStringFree (str2);
-
- ... Terry
-