-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Can't drag the cursor with the mouse #103002
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
Conversation
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.
Is the command there for a purpose?
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.
Nope I forgot it there, thanks for catching that.
53ac3a9 to
1205271
Compare
chunhtai
left a comment
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.
This seems to be a weird approach to disable mouse drag, I was wondering whether you can fix this by making _SelectionHandleOverlay to only accept touch gesture?
| case TargetPlatform.windows: | ||
| break; | ||
| case TargetPlatform.android: | ||
| case TargetPlatform.iOS: |
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.
what about iOS with blue tooth mouse?
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.
Good point, I should actually try that and see what happens. I'm not sure how it handles showing the handles or not.
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.
With the new solution, mobile platforms with a mouse will behave the same as desktop platforms with a mouse (clicking and dragging with a mouse will select, not drag the cursor).
|
The problem is that the underlying field needs to receive that drag gesture when using a mouse, so I would need to write a custom GestureDetector that receives touch drags but ignores mouse drags. My thought was that we shouldn't be building this invisible handle there anyway, but after looking into it my current way isn't the right way to do that. The place to decide if a handle should be built or not is TextSelectionControls, but I don't think I can fix it there without a breaking change. I'll investigate the touch-only GestureDetector and try to do that. Maybe I can look into a deeper refactor and not drawing the handle at all after my ContextMenu changes. |
|
@chunhtai I've implemented the touch-only gesture detector solution, ready for re-review. |
chunhtai
left a comment
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.
Code looks good, just concern about the supported devices.
| debugOwner: this, | ||
| // Selection handles can only be dragged by touch. Mouse | ||
| // events on the handle will select the text behind. | ||
| supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch }, |
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.
what about stylus?
and there is the wild card, PointerDeviceKind.unknown. as far as I know, adb comand and a11y command may use unknown. I think a11y is probably fine to be excluded. adb commands are usually used during integration test, which may expect to drag the selection handle. I am not sure whether that would be a valid use case though
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.
That makes sense, let me try adding stylus and unknown and make sure the tests still pass here.
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.
I added them plus separate tests for touch, stylus, and unknown (and the existing mouse test). Ready for re-review.
9aa8499 to
7ec74d3
Compare
chunhtai
left a comment
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.
LGTM
Previously, it was possible to click and drag the text selection cursor with the mouse. This should only be possible on mobile with touch gestures.
Fixes #102928