Re: XForms: three questions

Stephen Langer (langer@cam.nist.gov)
Fri, 20 Feb 1998 14:22:07 -0500

# To subscribers of the xforms list from "Stephen Langer" <langer@cam.nist.gov> :

> # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve
Lamont) :
>
> I don't think the single and double click callbacks were really meant
> to be used together. I suppose one could kluge something to avoid
> acting on the second single click callback by setting a flag in the
> double click callback to tell the single click callback to ignore the
> callback.

That would easily prevent acting on the second single click, but wouldn't
help to decide whether or not to act on the first one.

> The problem is, of course, disambiguating the single from the double
> click. You'll note that in most applications, a single click doesn't
> do much other than, for example, change the color or mode of an
> object. The double click does the actual work.

Yes. I guess I'm being nontraditional. In my program, a single click
performs an action with default values of some parameters, and a double click
brings up a window that lets the parameters be set before performing the
action. I could switch to using left and right mouse buttons to distinguish
the two modes, but test users seemed to prefer single vs double clicks.

>
> You don't really need to us SIGALRM to do your workaround. Simply use
> gettimeofday():
>
> #define SECS(tv) ( (tv).tv_sec + ( 1.0e-6 * (tv).tv_usec ) )
> #define DOUBLE_CLICK_TIME 0.25 /* I like about a 1/4 of a second */
>
> void callback( FL_OBJECT *ob, long data )
>
> {
>
> static double last_time = 0.0;
> struct timeval tv;
>
> gettimeofday( &tv, NULL );
>
> if ( SECS( tv ) - last_time <= DOUBLE_CLICK_TIME )
> do_the_double_click_stuff();
>
> last_time - SECS( tv );
>
> }

This doesn't work, because I never know when to do the single click stuff!

In my scheme, I do the single click stuff when the timer expires. If I get
a second click before the timer expires, I disable the timer and do the
double click stuff. However, the main event loop could keep checking the time
after a single click and call the single click callback when appropriate
without using an alarm. If the main loop called a single click callback for a
single click, and a double click callback (but no single click callback) for
a double click, then I doubt that any existing code would break, and the
double clicks would be useful in a much wider variety of applications. Would
it be possible to make it work this way, TC?

>
> > (2) Deleting and freeing grouped objects
> >
> > Does the order matter?
>
> Sort of. Here's what I'd do.
>
> [...]
>
> I've tested it in a limited sort of way and it seems to work.

Thanks!

-- Steve

-- 
-- EMail: stephen.langer@nist.gov                    Phone: (301) 975-5423 --
-- WWW:  http://math.nist.gov/mcsd/Staff/SLanger/    Fax:   (301) 990-4127 --
-- Mail: Building 820 Room 365; NIST; Gaithersburg, Md          20899-0001 --
_________________________________________________
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://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/