> Click always happens before double-click. If you don't want 
> it that way, you'll need to setTimeout in click to see if a 
> double-click arrives, then cancel the timer if it does. That 
> has the undesirable side effect of delaying the click effect 
> until you are sure that no double-click happens, and the 
> double-click time is user settable (e.g., Control Panel, Mouse in
> Windows) so there is no totally safe value that isn't also annoying.

Exactly right. Windows applications sometimes use this trick safely, because
they are able to query the double-click time and set the timeout
accordingly. You don't have access to this information in JavaScript.

But even when this can be done safely, it's something to be avoided. It's
better to rethink the UI, so that the action performed by a single click
does not interfere with the subsequent double click. The classic example is
the desktop in Windows or Mac, where a single click selects a document and a
double click opens it. Selecting the document does not interfere with
opening it, so there is no problem.

That is the only really good solution to this problem.

BTW, if the double-click event comes through before the single-click,
something is wrong. The single-click should always come first.

Also, Firefox has a serious bug in this area. A double-click in Firefox
results in *two* click events followed by the dblclick. The first click
fires a click event as expected, and then the double click fires another
click event before the dblclick. That second click event should definitely
not happen, and does not happen in IE. It's not a jQuery issue; the same
thing happens if you use "onclick/ondblclick" handlers.

This is all the more reason to make the click "non-destructive" if you are
also handling the double click.

-Mike


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to