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

  1. Xref: sparky comp.windows.x:15168 comp.windows.x.motif:5581
  2. Newsgroups: comp.windows.x,comp.windows.x.motif
  3. Path: sparky!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!timkwan
  4. From: timkwan@athena.mit.edu (Unknown)
  5. Subject: Re: How to simulate a ButtonPress/ButtonRelease event?
  6. Message-ID: <1992Aug12.205201.13361@athena.mit.edu>
  7. Sender: news@athena.mit.edu (News system)
  8. Nntp-Posting-Host: m11-113-14.mit.edu
  9. Organization: Massachusetts Institute of Technology
  10. References: <1992Aug10.154318.23759@athena.mit.edu>
  11. Date: Wed, 12 Aug 1992 20:52:01 GMT
  12. Lines: 48
  13.  
  14.  
  15. I asked a question a few days ago about simulating button
  16. press/release events to which some of you offered some suggestions.
  17. At any rate, I got it to "work" with the following:
  18.  
  19.   event.type = ButtonPress;
  20.   event.xbutton.send_event = True;
  21.   event.xbutton.display = dpy;
  22.   event.xbutton.window = currWin;  /* window where pointer is in NOW */
  23.   event.xbutton.x = 0;  /* 0 is arbitrary -- just somewhere inside the */
  24.   event.xbutton.y = 0;  /* widget will do.                             */
  25.   event.xbutton.state = 0;
  26.   event.xbutton.button = 1;
  27.   XtDispatchEvent(&event);
  28.   XmUpdateDisplay(toplevel);
  29.  
  30.   event.type = ButtonRelease;
  31.   event.xbutton.state = ButtonReleaseMask;
  32.   XtDispatchEvent(&event);
  33.   XmUpdateDisplay(toplevel);
  34.  
  35. It didn't work with XSendEvent -- that's puzzling.  But at least the
  36. above code works for my Motif pushbuttons.  I haven't tried it on
  37. arbitrary windows which listen for ButtonPress/Release events though.
  38.  
  39. I do have one sticky problem.  My other team member is using a menubar
  40. widget which he created.  I successfully moved the pointer to the
  41. desired menubar option (with XWarpPointer) but when I issued the button
  42. press and release events (the code above), the workstation 'hangs'
  43. after executing the second XtDispatchEvent().  All processes on the
  44. workstation appeared to continue running, and I could move the pointer
  45. around but I could no longer use the pointer to click on anything.
  46. Consequently I could move the pointer into an xterm, say, but could
  47. not type anything in there.  I had to reboot the workstation.
  48.  
  49. Is the code above incorrect or is there something amiss with my
  50. partner's custom menubar widget?  The menubar works fine when acted
  51. upon manually with either keyboard meta keys or mouse clicks.  I would
  52. think that as long as I generate the button press/release events
  53. EXACTLY LIKE those generated if I were to click the mouse manually,
  54. then everything should work fine.  Can someone please check the above
  55. code and tell me if that is sufficient in generating the button
  56. press/release events EXACTLY LIKE those produced from manual button
  57. clicks.
  58.  
  59. Please send me email directly.  Thanks.
  60.  
  61. -Tim
  62.