Bug Tracker

Modify

Ticket #7876 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

IE dblclick documentation error

Reported by: rtpmatt Owned by: rtpmatt
Priority: low Milestone: 1.6
Component: web Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description

The docs for dblclick say

It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events and others only one. If an interface that reacts differently to single- and double-clicks cannot be avoided, then the dblclick event should be simulated within the click handler. We can achieve this by saving a timestamp in the handler, and then comparing the current time to the saved timestamp on subsequent clicks. If the difference is small enough, we can treat the click as a double-click.

In IE (8 at least) however, the second click even is not fired, only the first click, then a dblclick.

 http://www.jsfiddle.net/b4ktR/

The best solution I have come up with is to use the timer as proposed, but if a dblclick event is fired, have it do what the timer would do in the case of a dblclick, cancel the timer, and return false; There is probably a better way, but that what I have right now.

Sorry if this is not the best place to post a documentation issue.

Change History

comment:1 Changed 3 years ago by ajpiano

  • Owner set to rtpmatt
  • Status changed from new to pending

Is this a docs error? It describes exactly what you do:

"The sequence of events triggered varies from browser to browser, with some receiving two click events and others only one."

Unless you are saying that it is *also* worth mentioning one could use a timeout based approach? Is that what you're getting at?

comment:2 Changed 3 years ago by anonymous

No, I am saying this is perfectly valid and true:

It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events and others only one.

but this:

the dblclick event should be simulated within the click handler.

obviously can't work in a browser that only fires a single click.

comment:3 Changed 3 years ago by dmethvin

obviously can't work in a browser that only fires a single click.

Sure it can, using the timer trick mentioned in the documentation. That's basically what either the browser or underlying operating system is doing to detect double clicks. I think the docs are okay as-is, but if you have some suggestions on rewording let us know.

It's a really bad idea to use double clicks in a web interface, it's not something that most people expect.

comment:4 Changed 3 years ago by RTPMatt

Unless I am missing something and just being an idiot (quite possible), if I only have a click handler, and the browser fires a click and then a dblclick, checking the time between click will do no good, as the second click will be ignored because I have nothing bound to dblclick. The second click event is not fired even if no event is bound to dblclick.

If instead I have something bound to click that does the time checking, and something bound to dblclick for the browsers that use only it, I will be double firing my dblclick in browsers that give me two clicks and a dblclick.

It's a really bad idea to use double clicks in a web interface, it's not something that most people expect.

I totally agree with that, however, if the docs propose a possible solution, I feel it should work, or not be provided.

I think the docs would be better if they did one of the following:

  1. Just stated the problem

It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events and others only one.

  1. State the problem and give some advice on how to fix it, but not make it sound like a complete solution if it is not.

It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click and one dblclick event and others only a single click and dblclick event. You can get around this by checking the time between click/dblclick events, and manually firing your event when appropriate.

  1. Providing a solid method to make it work. I do not have a good example for how to do this. I am sure it can be done, but I was more interested in making it work for my case than coming up with the perfect solution.

If you still disagree with me, please close this ticket and I will not bring it up again.

comment:5 Changed 3 years ago by dmethvin

  • Status changed from pending to closed
  • Resolution set to fixed

Ah, okay, I see what you are saying. The docs wording is ambiguous. I think it essentially means "making an element respond to both click and double-click is not a good idea. But you forge ahead and do it anyway, the solution may involve attaching both a click and double-click handler so it can work on all browsers." Does that sound right?

I think it may be best to remove any prescriptive attempt at a solution here, so that's what I've done. There is a user comment on the page that includes a link with code, in case anyone wants to do it.

comment:6 Changed 3 years ago by rtpmatt

Thank you, I very much like the "vary by operating system and browser, and is often user-configurable." as that has been on my mind a lot recently.

comment:7 Changed 3 years ago by john

  • Priority changed from undecided to low
  • Component changed from unfiled to web

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.