-
Notifications
You must be signed in to change notification settings - Fork 822
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
Double and triple click support #5339
Comments
@willmcgugan Thinking more about this. We could do this in a backwards compatible way without needing it to be opt-in. We'd have the existing That way, if users don't care about whether it's a single/double/triple click, they can continue to handle |
But what if you want to handle both a single and a double click? In that case you don't want the double click event to have been preceded by a click event. |
You'd have a handler for SingleClick and a handler for DoubleClick. |
But presumably a dev would want to distinguish between the two. If we send both events, then a double click would produce a Click followed by a DoubleClick after a short delay. At the time the Click handler is invoked, I can not know if it is part of a double click or a single click. |
Yeah, that's why I'm suggesting you'd handle the SingleClick event not the Click event. Every time you click, a Click event is fired immediately. Click once, the click event is fired immediately then after 50ms if you haven't clicked again a SingleClick is fired. Click twice in quick succession (less than say 50ms apart) and two Click events are sent immediately on each click as usual, then 50ms later if you haven't clicked again, a DoubleClick event is fired. |
Ah! Got you now. So a double click would produce I see how that would negate the need to opt-in. That does mean that if I decide I need to handle double clicks, I would have to switch my click handlers from TBH, that feels like much the same effort as opting in. With this system I would have to replace But that doesn't feel like a compelling argument for or against. I like this idea. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
We should support double and triple click events.
This may need to be opt-in, as we'll need to wait after the initial click to determine which type of event to send.
This could be used to unlock extra features in existing widgets, for example, double click to select a "word" in the
TextArea
, and triple click to select a line.The text was updated successfully, but these errors were encountered: