-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Use click event to determine modifier keys #22988
Use click event to determine modifier keys #22988
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
To reviewers:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the issue is that the existing click event forces you to pick either the down
or up
events to work with, and so there's bugs in existing code due to modifiers present in one or the other, is that correct?
If so, I think a simpler solution would be to create a method on ClickEvent
, maybe just modifiers()
and click_count()
, that computes this combined event that you are synthesizing here, and then fix the bugs upstream by calling this method. I don't think we want to hide the underlying nature of click events as being composed of two MouseEvents, as done in this PR.
It's not only that — the ClickEvent before this change was only ever emitted, manually, by the But that makes sense, I'm definitely not opposed to keeping the up and down properties on the ClickEvent and just adding The approach here is modeled after web browser's click event semantics, which doesn't contain any references to the associated mouse down or up events! |
True, it is a tradeoff of this approach. I think generally we prefer to push decisions like this up to client APIs though, and so you do have to re-implement this stuff more often.
That's a sensible approach we use most of the time as well, and I think that's the model we want the |
Ah, ok! This is very helpful to know, thank you. So then it sounds like the right approach would look more like:
Does that seem right? |
That does seem correct! |
e46e70d
to
3f44a7a
Compare
Ok, awesome,. Thanks for the guidance @mikayla-maki! I think I've implemented this as described now. I've confirmed that this approach also fixes the issue (at least for me, on Linux, with Wayland) |
Howdy! This is one of those things that I'm reminded of every day because I constantly trigger it haha. Just bumping this in case it was forgotten, totally understand that you all may have other priorities and that code review is work! |
Oh, funny.
This is only failing on Windows and macOS because that position_map argument is only used inside a |
I see a lot of green checkmarks! :D @mikayla-maki does this look good to you? |
@smoores-dev Please don’t spam the PR thread for reviews. We will get to this when we have bandwidth. |
Hi @smoores-dev, I've been heads down working on #22632, and am able to review PRs again!Unfortunately, it looks like that PR has caused several conflicts with this one. This implementation is looking really good though, I like having a proper click handler in the editor for all of that multicursor logic. Once the conflicts are resolved I'd be happy to merge this :D |
Previously, editor elements had to listen for mouse_up events to determine when a click had completed. This meant that they only had access to modifier keys that were pressed during the mouse_up event. This led to some incorrect user experiences, such as executing a ctrl+click if the user pressed ctrl after pressing the mouse button, but before releasing it. This change adds a click event handler to EditorElement, and adds a modifier() method to the ClickEvent, which only includes the modifier keys that were pressed during both mouse down and mouse up. The code for handling link clicks has been moved into the click event handler, so that it's only triggered when the non-multi-cursor modifier was held for both the mouse down and mouse up events.
Head branch was pushed to by a user without write access
5101a88
to
c9d4bd6
Compare
Yay, thanks @mikayla-maki! Just rebased onto main and pushed! |
Previously, editor elements had to listen for mouse_up events to determine when a click had completed. This meant that they only had access to modifier keys that were pressed during the mouse_up event.
This led to some incorrect user experiences, such as executing a ctrl+click if the user pressed ctrl after pressing the mouse button, but before releasing it.
This change adds a click event handler to EditorElement, and adds a modifier() method to the ClickEvent, which only includes the modifier keys that were pressed during both mouse down and mouse up. The code for handling link clicks has been moved into the click event handler, so that it's only triggered when the non-multi-cursor modifier was held for both the mouse down and mouse up events.
Closes #12752, #16074, #17892 (the latter two seem to be duplicates of the former!)
Release Notes: