Re: XForms: Events

Stefano Incontri (stefano.in@iol.it)
Wed, 24 Jun 1998 15:39:22 +0200

# To subscribers of the xforms list from Stefano Incontri <stefano.in@iol.it> :

Steve Lamont wrote:
>
> # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
>
> > Xforms library is very good, but i don't understand how does it work
> > the Event mechanism. I.e., if i'd like to execute a function when
> > the mouse pass on (or focus on) a button or whatever else (like a
> > form), how can I bind the function or the object with the event
> > (FL_FOCUS or FL_ENTER) ?
>
> To get at those events you'll have to install either a pre-emptive or
> post object handler.
>
> For instance, if you have an object called `bar' in a form called
> `bar', you'd do something like
>
> FD_bar *bar = create_form_bar();
>
> [...]
>
> fl_set_object_posthandler( bar->foo, foo_handler );
>
> [...]
>
> int foo_handler( FL_OBJECT *ob, int event, FL_Coord mx, FL_Coord my,
> int key, void *raw_event )
>
> {
>
> switch ( event ) {
>
> case FL_FOCUS: {
>
> do_your_focus_thing();
> break;
>
> }
> case FL_ENTER: {
>
> do_your_enter_thing();
> break;
>
> }
>
> [...]
>
> }
>
> return !FL_PREEMPT; /* Actually, can return anything from a */
> /* post object handler */
>
> }
>
> I suggest using a post object handler because the post object handler,
> as the manual says, gets all events, while the pre-emptive handler
> often only gets a subset of events internally defined by XForms, among
> other reasons.
>
> Refer to the chapter "Using a pre-emptive handler" in the manual for
> details.
>
> spl
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuf2.usuhs.mil or see
> http://bob.usuf2.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/

Thank you very much!
The post object handler solution seems to be very good, also a "raw
callback handler" is good also if it's a preemptive handler.
For curiosity, it would not be possible (as idea) to 'register' only one
event for object, binding it with a callback?

Thank you a lot,
Best Regards, Stefano
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/