PricingBlog

Click vs Double Click

  • nigelg_-1212358433349574696

    Nigel G

    1 year ago

    Hi there.

    I was messing about with the + / - button tutorial and tried to make a double click on the + add 10 to the variable.

    What actually happened was it added 12. So counted a double click as two clicks and a double click.

    Is this a bug, or is there some way to prevent this?
  • nigelg_-1213056507642650654

    Nigel G

    1 year ago

    No? Seems like a pretty fundamental bug to me.
  • jacobkofoed-1213064147659653172

    Jacob Kofoed

    1 year ago

    This is an age old issue in handling dblclick events. Basically there is no way to determine if the first click is a click or the first part of a double-click. Not without adding a noticeable delay.

    It comes a bit down to each case. In your example you could simply add 8 on a double-click, as each click adds an additional one. Alternative you could rely on only click with some timers to check time between clicks yourself, and then add either 1 or 10 if a second click comes in within the time given. However, a warning for that would be that each click would have a substantial delay and make your counter seem unresponsive on normal clicks.

    The best UX in your case would probably be to stay away from double clicks entirely and rely on ´SHIFT´ + click or even a separate button called "+10".
    👍1