-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Text selection via mouse #28290
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
Text selection via mouse #28290
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.
Needs a one-sentence summary.
|
My general feedback is we're trying to remove RenderEditable from the business of translating raw user events into platform specific business logic. It should have text related APIs (e.g. put cursor here, select words between these range) rather than event related APIs (e.g. do something given a double tap, do something given a drag etc). This is mainly because different platforms do different things and users should be free to use a low-level RenderEditable to do whatever they want to drive it to do. Concretely, don't add more recognizers into the RenderEditable (they're just there for fallback and we should eventually do it by composition rather than increasing the RenderEditable's role). Let the listeners of TextSelectionGestureDetector tell the RenderEditable specifically what it should do in consequence of user actions. |
mdebbar
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.
@xster that makes sense.
49f9e80 to
910f313
Compare
xster
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
|
Also I don't know how widely done subclassing gestures is done in google3. I would be on the lookout during the next roll to make sure the codebase correctly migrates to addallowedpointer |

Description
Add the ability to select text using a mouse device. Currently Flutter only allows text selection through taps, long presses, force presses or keyboard. Using a mouse, the intuitive way to select text is by clicking and dragging.
As part of this PR, I'm also changing the behavior of long presses in text fields. Long presses coming from a mouse will no longer select the whole word, it'll behave like a normal tap for text selection purposes. Touch long presses will still work as expected.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?