Sender: owner-xforms@bob.usuf2.usuhs.mil
Precedence: bulk
Reply-To: xforms@bob.usuf2.usuhs.mil
# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
> If I register a prehandler for an object so that I can handle DBLCLICK
> events in a sneaky-ish kind of way, I need to return 0 in the event of
> a CLICK event. However, it seems from my experimentation that any
> DBLCLICK event is preceeded by a CLICK event, and thus if the object's
> regular handler is not DBLCLICK aware (as for, example, the button
> handler is not), the user ends up signalling both kinds of events,
> with pretty undesirable results.
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.
Obviously, the case where you want to process both FL_DBLCLICK and
FL_PUSH (or FL_RELEASE) events, then the situation becomes much more
complicated, since you must somehow be able to handle the FL_PUSH
event retrospectively, as it were.
One method might be to use a timeout callback, which could be cleared in
the event of a FL_DBLCLICK. Here's an example of a prehandler which
discriminates between double and single clicks. If it does not get a
second click withing 250 msec, which is a pretty standard timeout
period, the timeout calls the single click handler. Otherwise, it calls a
double click handler:
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;
}
No callback is registered for the object itself -- the handling of the
object event is handled in either the prehandler or the single_click
handler.
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/
-- Helmut Bohr Helmut.Bohr@T-Online.de hbohr@dvo.de _________________________________________________ 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/