[comp.windows.x] How do I simulate Command button event?

mh2620@sarek.Berkeley.EDU (Mark Horstman [235-3417]) (09/11/90)

I'm trying to simulate a button press/release event in a Athena Command
widget but can't seem to get it to work.  I'm using XSendEvent.  Do I
have to fill the whole XButtonEvent structure?  Do I have to send a 
press event followed by a release event or can I just send the release
event?

I have the O'Reilly manuals (0,1,2,4,5) but can't find a detailed 
explanation on how to send events.

 +----------------------------------------------------------------------------+
 | Mark A. Horstman                               Southwestern Bell Telephone |
 | mh2620@sarek.sbc.com                                         St. Louis, MO |
 |   OR uunet!sarek.sbc.com!mh2620                             (314) 235-3417 |
 +----------------------------------------------------------------------------+

klee@wsl.dec.com (Ken Lee) (09/12/90)

In article <1990Sep11.095335@sarek.Berkeley.EDU>, mh2620@sarek.Berkeley.EDU (Mark Horstman [235-3417]) writes:
|> I'm trying to simulate a button press/release event in a Athena Command
|> widget but can't seem to get it to work.  I'm using XSendEvent.

I'm not sure what you're trying to do, but Xt accelerators might be
much easier.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

marbru@auto-trol.UUCP (Martin Brunecky) (09/12/90)

In article <1990Sep11.095335@sarek.Berkeley.EDU> mh2620@sarek.Berkeley.EDU (Mark Horstman [235-3417]) writes:
>I'm trying to simulate a button press/release event in a Athena Command
>widget but can't seem to get it to work.  I'm using XSendEvent.  Do I
>have to fill the whole XButtonEvent structure?  Do I have to send a 
>press event followed by a release event or can I just send the release
>event?
>
   You better do both, though for Xaw command I think you don't need
  to worry about x,y. If you don't send both press/release, something
  in the widget can get out of sync, especially since you can not manufacture
  the cative button grab normally activated by the server. 
  Your problem may be the target window (I don't know what method you
  use to determine it, or may be some other field in the event structure.

  I am sending a pointer event to the current pointer position, looking
  for a window underneath the pointer, and it works fine.

-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                   marbru@auto-trol.COM
(303) 252-2499                    {...}ncar!ico!auto-trol!marbru
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

cjmchale@swift.cs.tcd.ie (09/13/90)

In article <1990Sep11.095335@sarek.Berkeley.EDU>, mh2620@sarek.Berkeley.EDU (Mark Horstman [235-3417]) writes:
> I'm trying to simulate a button press/release event in a Athena Command
> widget but can't seem to get it to work.  I'm using XSendEvent.  Do I
> have to fill the whole XButtonEvent structure?  Do I have to send a 
> press event followed by a release event or can I just send the release
> event?

I think this belongs on the frequently asked questions posting :-(


It is very likely that you're not setting the "window" field in the event
before using XSendEvent(). The event is getting sent to the correct
application and then Xt says to itself "I don't have any widget whose
window id matches that in this event structure" so it simply (and silently)
throws away the offending event.

If you're sending events to your own application (and it sounds like
you are) then you can use XtDispatchEvent() instead. This is more
efficient that XSendEvent() since everything is done locally
(i.e, you're avoiding a round trip to the X server). If using
XtDispatchEvent() then (as for XSendEvent()) remember to set the
"window" field in the event before using XtDispatchEvent().

> | Mark A. Horstman                               Southwestern Bell Telephone |
> | mh2620@sarek.sbc.com                                         St. Louis, MO |
> |   OR uunet!sarek.sbc.com!mh2620                             (314) 235-3417 |
> +----------------------------------------------------------------------------+

Regards,
Ciaran.
-- 
Ciaran McHale
Department of Computer Science, Trinity College, Dublin 2, Ireland.
Telephone: +353-1-772941 ext 1538    FAX: +353-1-772204   Telex: 93782 TCD EI
email: cjmchale@cs.tcd.ie	or	cjmchale%cs.tcd.ie@cunyvm.cuny.edu
	My opinions are mine but you can share them too if you want.