[comp.windows.x] How do I bind multiple functions to a buttonpress?

kevin@edstip.EDS.COM (Kevin Brown) (04/05/91)

Using Motif 1.0 and X11R4, is it possible to bind multiple functions
to one button press event.  I know that twm contains a function called
f.function, which allows the user to name and create a function.  Is 
there an equivalent in Motif?

Thanks in advance.

Kevin Brown		    |  kevin@edstip.eds.com
Electronic Data Systems     |  
800 Tower Drive		    |  Voice: (313) 265-9232
Troy, MI 48013	 	    |  Fax:   (313) 265-9241
-- 
 Kevin Brown		    |  kevin@edstip.eds.com
 Electronic Data Systems    |  
 800 Tower Drive	    |  Voice: (313) 265-9232
 Troy, MI 48013 	    |  Fax:   (313) 265-9241

cjmchale@cs.tcd.ie (Ciaran McHale) (04/06/91)

In <922@edstip.EDS.COM> kevin@edstip.EDS.COM (Kevin Brown) writes:

>Using Motif 1.0 and X11R4, is it possible to bind multiple functions
>to one button press event.  I know that twm contains a function called
>f.function, which allows the user to name and create a function.  Is 
>there an equivalent in Motif?

Use XtAddCallback() to bind function foo to the ButtonPress event on a
widget. Then use XtAddCallback() again to bind function bar to the
widget for the same event type. Guess what? Both functions (foo and bar)
will be invoked (in order of their binding) when the button is
pressed in the widget. Amazing, isn't it :-)

And now for my next trick ... :-)


Ciaran.
-- 
Ciaran McHale           "There's a lot to be said for verbosity."     ----
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

mikey@sgi.com (Mike Yang) (04/07/91)

In article <1991Apr5.175019.14043@cs.tcd.ie> cjmchale@cs.tcd.ie (Ciaran McHale) writes:
>In <922@edstip.EDS.COM> kevin@edstip.EDS.COM (Kevin Brown) writes:
>Use XtAddCallback() to bind function foo to the ButtonPress event on a
>widget. Then use XtAddCallback() again to bind function bar to the
>widget for the same event type. Guess what? Both functions (foo and bar)
>will be invoked (in order of their binding) when the button is
>pressed in the widget. Amazing, isn't it :-)

Be careful.  Although the current Xt implementation may call the
callbacks for the same event type in order of their binding, the
documentation specifically says that the ordering is unspecified.

Therefore, if you require a specific ordering, you should add a single
callback which performs your operation in the desired sequence.

-----------------------------------------------------------------------
                 Mike Yang        Silicon Graphics, Inc.
               mikey@sgi.com           415/335-1786