Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click count on Pointer Events #3899

Open
xorgy opened this issue Sep 4, 2024 · 0 comments
Open

Click count on Pointer Events #3899

xorgy opened this issue Sep 4, 2024 · 0 comments
Labels
S - api Design and usability S - enhancement Wouldn't this be the coolest?

Comments

@xorgy
Copy link

xorgy commented Sep 4, 2024

Click counting for double and triple clicks is a common need, and on some platforms is hard to address if they aren't determined in winit. In particular the Mac doesn't have a readily accessible API for getting the double click interval or detection rectangle separate from an individual event.

Some notes on implementation:

  • on Mac, NSEvent has clickCount; easy. (there is also a doubleClickInterval attached to the NSEvent)
  • Windows has an easy way to query the double click interval (GetDoubleClickTime) and a standard double click rectangle (SM_CXDOUBLECLICK/SM_CYDOUBLECLICK accessible with GetSystemMetrics), which is widely interpreted as extending to multiple clicks (e.g. in the WPF implementation and some browsers).
  • Neither X11 and Wayland themselves bother to expose an interval setting, nor is there a count on mouse button events; it's left up to toolkits to decide where to look for a click interval setting, if there even is one (some toolkits don't bother exposing the option). Chromium just hardcodes a 500ms interval and a 4px rectangle on platforms that don't handle it specifically, these are the Windows defaults.
  • Android doesn't specify any standard way to store this preference (and doesn't encode count on MotionEvent), which could be an issue for the minority of people who use mice with Android apps (on ChromeOS and DeX); could again just go with some well-known values (like Chromium and others do, when they need to synthesize a click count on a platform that doesn't have readily accessible settings)
  • On the web, click count is exposed in the detail property of mousedown/mouseup events, and browsers generally expose the best available platform behavior.

Overall, I think this would be not terribly hard to implement in a useful way; and even on platforms where there are shortcomings, it's better than not having it at all.

Blocked on #3833.

@xorgy xorgy added the S - enhancement Wouldn't this be the coolest? label Sep 4, 2024
@madsmtm madsmtm added the S - api Design and usability label Sep 4, 2024
@madsmtm madsmtm added this to the Version 0.31.0 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - api Design and usability S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

2 participants