Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!brazeau.ucs.ualberta.ca!unixg.ubc.ca!ubc-cs!uw-beaver!zephyr.ens.tek.com!uunet!cis.ohio-state.edu!ucbvax!vaxa.nerc-murchison.ac.uk!E_CMA From: E_CMA@vaxa.nerc-murchison.ac.uk Newsgroups: comp.windows.x Subject: Re: POPUP menu issue continue ... Message-ID: <9106282116.AA16358@ucbvax.Berkeley.EDU> Date: 28 Jun 91 10:55:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 96 > The second one remains for which I could not popup different menus by > depressing different buttons(Button1, Button2, and Button3). I only can > get one by btn3. You would appear to be missing a few bits of code. Your event loop picks up the generic keypress events but only recognises Button3 events as relevant to popup menus. (See the documentation for the attributes of XmRowColumn.) To override this you must set the XmNwhichButton resource for the menus you attach to each mouse button.... In main() ...setting XmNwhichButton for each menu... (if you are using XmCreatePopupMenu, put these in the argument lists) XtSetArg(wargs[0], XmNwhichButton, Button1); XtSetValues(menu_1,wargs,1); XtSetArg(wargs[0], XmNwhichButton, Button2); XtSetValues(menu_2,wargs,1); XtSetArg(wargs[0], XmNwhichButton, Button3); XtSetValues(menu_3,wargs,1); Alternatively, you can set the XmNwhichButton resource in the UIL file if you use one, where your popup menus are defined as unmanaged children of your drawing area widget. I prefer that method myself. Button3 is the default button for popups, which is why that works already. /* * set up event handlers for each of the popup menus * insert these just before your event loop */ XtAddEventHandler(host_widget, /* = widget within which the event is recognised*/ ButtonPressMask, False, post_menu, menu_1); /* then do the same for menu_2 and menu_3... */ XtAddEventHandler(host_widget, ButtonPressMask, False, post_menu, menu_2); XtAddEventHandler(host_widget, ButtonPressMask, False, post_menu, menu_3); ... /* * -------------------------------------------------------------------------- * post_menu () * * c.f.from Young p97 make popup menu appear at sprite position * -------------------------------------------------------------------------- */ void post_menu (Widget w, Widget menu, XEvent *event) { Arg wargs[10]; int button; XtSetArg(wargs[0], XmNwhichButton, &button); XtGetValues(menu, wargs, 1); if(event->xbutton.button == button) { XmMenuPosition(menu,event); XtManageChild(menu); } } /* * === End of post_menu_handler ========================================= */ I hope the above will be of help Cheers Carolyn Allen ************************************************************************* * Snailmail: * E_Mail * * * CBS%UK.AC.NERC-MURCHISON.VAXA::E_CMA * * Dr C.M.Allen * JANET: e_cma@uk.ac.nmh.va * * British Geological Survey * * * Murchison House * * * West Mains Road ** * * * * * Edinburgh * Tel: 031-667-1000 x277 from U.K. * * Scotland * * * EH9,3LA * * *************************************************************************