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