-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Double-click events #23874
Copy link
Copy link
Closed
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Needs-TriageThis issue needs to be labelledThis issue needs to be labelled
Metadata
Metadata
Assignees
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Needs-TriageThis issue needs to be labelledThis issue needs to be labelled
Type
Projects
Status
Done
What problem does this solve or what need does it fill?
Multiple users have requested support for double-click events.
What solution would you like?
On desktop platforms, the double click interval is a user preference in the system settings. Unfortunately, this setting is not currently exposed through winit, although it might be possible using platform-specific APIs like windows-sys.
For the short term, we can just go with a fixed constant, perhaps hidden behind an API that would let us migrate to the OS setting in the future.
The other requirement of double-click processing is detecting pointer movement: rapidly clicking on two different places on the screen is not generally considered a double-click. There are a few ways this can be done:
From an API standpoint, the most straightforward approach would be to add a new field on the
Clickevent. This can be a simple boolean, which if true means that the current click is sufficiently close (both spatially and temporally) to the previous click to be considered a double-click. Triple- and Quadruple-clicks can be handled by a state machine in application code, we don't need to build support for this into Bevy itself.What alternative(s) have you considered?
An alternative is to have consumers of click events do the double-click detection themselves, although this would most likely lead to inconsistent behavior.