Re: XForms: how to handle DBLCLICK and not CLICK in a {pre,post}handler ?

Paul Barton-Davis (pbd@Op.Net)
Thu, 17 Sep 1998 13:00:18 -0300

# To subscribers of the xforms list from Paul Barton-Davis <pbd@Op.Net> :

>If all you're interested in is the FL_DBLCLICK event, then simply
>return FL_PREEMPT in the case of a FL_PUSH or FL_RELEASE event.

Ah, for inheritance... what I really wanted to accomplish was, in
effect:

fl_button_add_dblclick_handler(FL_OBJECT, callback_func, arg);

since I want the functionality associated with the regular button
handler to still be used for every event except dblclick's, where the
pre (or post) handler would do the right thing.

>second click withing 250 msec, which is a pretty standard timeout

BTW, although the dbclick timeout-setting function is mentioned in the
manuals and declared in the header, the default value is not stated anywhere.

>void single_click( int id, void *data )
>
>{
>
> FL_OBJECT *ob = ( FL_OBJECT *) data;
>
> ob->u_ldata = 0;
>
> /* do your single click stuff */
>
>}
>
>int prehandler( FL_OBJECT *ob, int event, FL_Coord mx, FL_Coord my,
> int key, void *raw_event )
>
>{
>
> if ( event == FL_PUSH ) {
>
> if ( ob->u_ldata ) {
>
> fl_remove_timeout( ob->u_ldata );
> ob->u_ldata = 0;
>
> /* do your double click stuff */
>
> } else
> ob->u_ldata = fl_add_timeout( 250, single_click, ( void *) ob );
>
> }
>
> return !FL_PREEMPT;
>
>}

An elegant solution, as usual, except that I want the single_click()
function to do whatever the original button handler did, which I
presume means I have to:

fl_set_button (button_obj, on_or_off);
fl_call_object_callback (button_obj, whatever);

from within the single_click() routine, *and* I have to manage its
"on-or-offness" too. Is there a shortcut around this - some way to say
"I want a single click to work just the regular button handler thinks
it should ?" What would be nice, heh, heh, is if the pre-handler could
return not just 0 or FL_PREEMPT, but FL_PUSH etc. and the main handler
would get this returned event type instead. This of course is
difficult given the return type's simplicity compared to the
information that would be needed to "synthesize" a different event
type.

--p
_________________________________________________
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/