Skip to content

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Feb 21, 2019

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

Copy link
Contributor

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.

@xster
Copy link
Member

xster commented Feb 22, 2019

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.

@zoechi zoechi added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: gestures flutter/packages/flutter/gestures repository. labels Feb 22, 2019
Copy link
Contributor Author

@mdebbar mdebbar left a 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.

@gspencergoog
Copy link
Contributor

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@mdebbar mdebbar mentioned this pull request Feb 28, 2019
4 tasks
@mdebbar mdebbar requested a review from xster March 1, 2019 00:15
Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xster
Copy link
Member

xster commented Mar 1, 2019

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

@mdebbar mdebbar merged commit b94bf87 into flutter:master Mar 1, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: text input Entering text in a text field or keyboard related problems f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants