home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / motif / 8362 < prev    next >
Encoding:
Text File  |  1993-01-06  |  2.3 KB  |  68 lines

  1. Newsgroups: comp.windows.x.motif,80,articles
  2. Path: sparky!uunet!mcsun!ub4b!news.cs.kuleuven.ac.be!gate!joyce!johanb
  3. From: johanb@joyce.esat.kuleuven.ac.be (Johan Buelens)
  4. Subject: Re: controlling an option menu from within the program (summary)
  5. Message-ID: <1993Jan6.102718.2140@gate.esat.kuleuven.ac.be>
  6. Keywords: option menu
  7. Sender: news@gate.esat.kuleuven.ac.be (USENET News System)
  8. Organization: K.U.Leuven, Belgium
  9. References: <1992Dec30.205716.17673@gate.esat.kuleuven.ac.be>
  10. Date: Wed, 6 Jan 1993 10:27:18 GMT
  11. Lines: 55
  12.  
  13.  
  14. many thanks to everybody who responded !  as jasper@einstein.com pointed
  15. out, `The menuHistory resource must be set to the XmPushButton *widget* that
  16. you want to be selected.'
  17.  
  18. you can use the convenience functions to create the option menu, but then
  19. you have to find out the names of the pushbutton widgets and the menu widget;
  20. it then seems more appropriate to create the menu `the hard way' (without 
  21. convenience function), so you are in control of all the widget names.
  22.  
  23. the following code fragment does the trick:
  24.  
  25.                                         /* generate a pulldown menu            */
  26.     software_optionsubmenu_volume=XmCreatePulldownMenu(software_rowcol,
  27.             "optionsubmenu",NULL,0);
  28.                                         /* generate the menu choices        */
  29.     for(i=0;i<NUMBER_OF_VOLUMES;i++) {
  30.         software_optionsubmenu_volume_choice[i]=
  31.                 XmCreatePushButtonGadget(software_optionsubmenu_volume,
  32.                 cardinals[i+1],NULL,0);
  33.     }
  34.                                         /* manage the pulldown menu            */
  35.     XtManageChildren(software_optionsubmenu_volume_choice,NUMBER_OF_VOLUMES);
  36.  
  37.                                         /* create the option menu            */
  38.     compound_string=XmStringCreateSimple("volume      ");
  39.     ac=0;
  40.     XtSetArg(args[ac],XmNsubMenuId,software_optionsubmenu_volume);        ac++;
  41.     XtSetArg(args[ac],XmNlabelString,compound_string);                    ac++;
  42.     software_optionmenu_volume=XmCreateOptionMenu(software_rowcol,"optionmenu",
  43.             args,ac);
  44.                                         /* manage the whole thing            */
  45.     XtManageChild(software_optionmenu_volume);
  46.  
  47.  
  48. this menu can be reset simply by:
  49.  
  50.  
  51.     XtVaSetValues(software_optionmenu_volume,XmNmenuHistory,
  52.             software_optionsubmenu_volume_choice[0],0);
  53.  
  54.  
  55. thanks again,
  56.  
  57.  
  58. johan -b
  59.  
  60.  
  61. ---------------------------
  62. Johan H. BUELENS
  63. K.U.Leuven / ESAT / K. Mercierlaan 94 / B - 3001  Heverlee / Belgie
  64. phone  : (32) (16) 20 09 31 ext. 1076
  65. fax    : (32) (16) 22 18 55
  66. e-mail : johanb@esat.kuleuven.ac.be  (preferred)
  67.          buelens@imec.be, fheaa00@blekul11.bitnet
  68.