home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / motif / 5818 < prev    next >
Encoding:
Text File  |  1992-08-25  |  3.0 KB  |  122 lines

  1. Newsgroups: comp.windows.x.motif
  2. Path: sparky!uunet!centerline!noc.near.net!inmet!reatta!mep
  3. From: mep@reatta.camb.inmet.com (Mark Polhamus)
  4. Subject: button3 -> popup menu?
  5. Message-ID: <1992Aug25.205458.4927@inmet.camb.inmet.com>
  6. Sender: news@inmet.camb.inmet.com
  7. Nntp-Posting-Host: reatta
  8. Organization: Intermetrics Inc.
  9. Date: Tue, 25 Aug 1992 20:54:58 GMT
  10. Lines: 110
  11.  
  12. I'm trying to use an event handler to bring up a popup menu from an
  13. XmDrawnButton widget on a mouse button 3 press.  This usually works, but
  14. in certain cases the mouse button 3 event is not delivered.
  15.  
  16. Here's the (approximate) code used to set up the handler:
  17.  
  18. /*ARGSUSED*/
  19.     static void
  20. event_handler(pb, client_data, event)
  21.     Widget               pb;
  22.     XtPointer            client_data;
  23.     XButtonPressedEvent *event;
  24. {
  25.     ESS_ITEM_TYPE *item;
  26.     Widget         menu;
  27.  
  28.     if (event->button != 3 ) {
  29.         return;
  30.     }
  31.  
  32.     XmMenuPosition(menu, event);
  33.     XtManageChild(menu);
  34. }
  35.  
  36.     ...
  37.     XtAddEventHandler(widget, ButtonPressMask, False,
  38.         event_handler, (XtPointer)NULL);
  39.     ...
  40.  
  41. I'll sketch out the widget hierarchy below.  (I would show some source
  42. code, but I'm using TeleUSE to generate the widget hierarchy (only) and
  43. the generated .c file  reads poorly)
  44.  
  45. ApplicationShell
  46.     XmMainWindow
  47.         XmMenubar
  48.         XmCascadeButton
  49.         XmCascadeButton
  50.         XmPulldownMenu
  51.             XmPushButton
  52.         XmPulldownMenu
  53.             XmPushButton
  54.     XmForm
  55.         XmForm
  56.         XmRowColumn
  57.             XmForm
  58.             XmDrawnButton
  59.             XmText
  60.             XmText
  61.             XmForm
  62.             XmDrawnButton
  63.             XmText
  64.             XmText
  65.         XmRowColumn
  66.             XmLabel
  67.             XmLabel
  68.             XmLabel
  69.             XmLabel
  70.     XmScrolledWindow
  71.         XmBulletinBoard
  72.         XmForm
  73.            XmDrawnButton
  74.             XmText
  75.             XmText
  76.  
  77.     TopLevelShell
  78.         XmMainWindow
  79.         XmMenuBar
  80.         XmForm
  81.             XmForm
  82.                 XmPushButton
  83.                 XmPushButton
  84.             XmScrolledText
  85.             XmScrolledWindow
  86.             XmBulletinBoard
  87.                     XmForm
  88.                     XmDrawnButton*
  89.                     XmText
  90.                     XmText
  91.  
  92.  
  93. All of the XmDrawnButton widgets have the ButtonPressed event handler
  94. registered.  Only the last one (with asterisk) is getting any mouse
  95. button 3 events, they all get mouse button 2 events.
  96.  
  97. In addition, when I press mouse button 3 within the ApplicationShell's
  98. window (not the popup TopLevelShell), the cursor changes to slant to the
  99. right for a short time, then changes back.
  100.  
  101.  
  102. Questions:
  103.  
  104.     - Who's stealing my mouse button 3 pressed event?  (presumably the
  105.       same agent changing the cursor)
  106.  
  107.     - Is there a better way to bring up a popup menu for an arbitrary
  108.       widget?  I'm using the method suggested in O'Reilly's volume six
  109.       (_Motif Programming Manual for OSF/Motif Version 1.1_ by Dan Heller)
  110.       in Chapter 16, Pp. 560.
  111.  
  112.     - Although Heller warns that catching arbitrary events may interfere
  113.       with standard widget behavior, He says that Button 3 events are
  114.       safe since Motif doesn't use it.  Has this changed?  (We are using
  115.       Motif 1.1)
  116.  
  117. (if you've read this far, thanks for your consideration!)
  118.  
  119.  
  120. -- Mark Polhamus
  121. -- mep@inmet.inmet.com
  122.