home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / windows / x / motif / 8772 < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.0 KB  |  56 lines

  1. Newsgroups: comp.windows.x.motif
  2. Path: sparky!uunet!think.com!paperboy.osf.org!paperboy!drand
  3. From: drand@spinner.osf.org (Douglas S. Rand)
  4. Subject: Re: popping up a PopupMenu using Btn1
  5. In-Reply-To: fladmoe@unislc.uucp's message of Fri, 22 Jan 1993 16:00:53 GMT
  6. Message-ID: <DRAND.93Jan22174724@spinner.osf.org>
  7. Sender: news@osf.org (USENET News System)
  8. Organization: Open Software Foundation
  9. References: <C14G2D.Gvu@csn.org> <1993Jan22.160053.24231@unislc.uucp>
  10. Date: 22 Jan 93 17:47:24
  11. Lines: 43
  12.  
  13. In article <1993Jan22.160053.24231@unislc.uucp> fladmoe@unislc.uucp (Gary Fladmoe) writes:
  14.  
  15.    In article <C14G2D.Gvu@csn.org> tom@teal.csn.org (Tom Schutter) writes:
  16.    >I am constructing a toolbar where some buttons do actions when pushed, and
  17.    >others bring up popup menus. To make things consistent, I want the popup
  18.    >menus to come up with Btn1.
  19.    > 
  20.    >I start with a RowColumn (of type XmWORK_AREA) with a number of PushButton
  21.    >children. An activate callback on each PushButton then either calls one of
  22.    >my action callbacks or calls XmMenuPosition and XtManageChild to popup a menu.
  23.    > 
  24.    >The problem is that Btn1 pops the menu up, but only Btn3 will pop it down.
  25.    >...
  26.  
  27.    The following function violates the rule against using the Widget's private
  28.    data, but it seems to work:
  29.  
  30.    #include <Xm/RowColumnP.h>
  31.    void MenuButtonCB(w, menu, cbs)
  32.    Widget w;
  33.    Widget menu;
  34.    XmAnyCallbackStruct *cbs;
  35.    {
  36.        XButtonPressedEvent *event;
  37.  
  38.        event = (XButtonPressedEvent *)(cbs->event);
  39.        XmMenuPosition(menu, event);
  40.        XtManageChild(menu);
  41.        if (event->type == ButtonPress)
  42.            RC_PostButton(menu) = event->button;
  43.    }
  44.  
  45.  
  46. Naughty, naughty, playing with a widget's privates :) .  Seriously,
  47. don't do this.  This is not the only thing which must happen.  That is
  48. why there is a data abstraction layer between you and the widget
  49. internals.
  50.  
  51. --
  52. Douglas S. Rand <drand@osf.org>        OSF/Motif Dev.
  53. Snail:         11 Cambridge Center,  Cambridge,  MA  02142
  54. Disclaimer:    I don't know if OSF agrees with me... let's vote on it.
  55. Amateur Radio: KC1KJ
  56.