home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / motif / 5627 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  1.9 KB

  1. Path: sparky!uunet!usc!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!oceanroutes.ns.ca!deveau
  2. From: deveau@oceanroutes.ns.ca ("Terry J. Deveau")
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Re: Ctrl<Key>q to quit
  5. Message-ID: <9208141853.AA28389@BU.EDU>
  6. Date: 14 Aug 92 18:53:09 GMT
  7. Sender: sklower@ucbvax.BERKELEY.EDU
  8. Distribution: inet
  9. Organization: Oceanroutes Canada Inc.
  10. Lines: 47
  11.  
  12. > From: hoswell@tramp.colorado.edu
  13. >
  14. > > From: deveau@oceanroutes.ns.ca
  15. > >
  16. > > > From: hoswell@tramp.colorado.edu
  17. > > 
  18. > > >I'm having a bit of a problem setting a simple default translation...
  19. > > >
  20. > > >All I want to do is have a Quit routine called when I hit Ctrl<Key>q.
  21. > > >
  22. > > >I've tried this:
  23. > > >
  24. > > >static XtActionsRec actionsTable[] = {
  25. > > >    {"bye", Quit},
  26. > > >};
  27. > > >static char         defaultTranslations[] = "Ctrl<Key>q: bye()";
  28. > > 
  29. > > Have you considered using an XmAccelerator instead?
  30. > > 
  31. > uh, no - simply because I don't know how!  I understand that, for instance,
  32. > I can have a 'Quit' button and have an 'Accelerator' associated with it...
  33. > Is it easy to set up?
  34.  
  35. Yes it is easy to set up.  See the XmNaccelerator and XmNacceleratorText
  36. resources of the XmPushbuttonGadget widget (as inherited from
  37. XmLabelGadget).  Note that it only works if the push button is in a
  38. pulldown or popup menu pane (see FAQ-Motif, subject 59).  The code
  39. below should give you the general idea:
  40.  
  41.     int n;
  42.     Arg arg[10];
  43.     XmString str, str2;
  44.     Widget pushbutton, menuPane;
  45.  
  46.     n = 0;
  47.     str = XmStringCreateLtoR ("Button Label", XmSTRING_DEFAULT_CHARSET);
  48.     XtSetArg(arg[n], XmNlabelString, str); n++;
  49.     XtSetArg(arg[n], XmNaccelerator, "Ctrl<Key>q: bye()"); n++;
  50.     str2 = XmStringCreateLtoR (" (^Q)", XmSTRING_DEFAULT_CHARSET);
  51.     XtSetArg(arg[n], XmNacceleratorText, str2); n++;
  52.  
  53.     pushbutton = XmCreatePushbuttonGadget(menuPane,"pushbutton", arg, n);
  54.     XmStringFree (str);
  55.     XmStringFree (str2);
  56.  
  57. ... Terry
  58.