Add support for double tap and drag for text selection#109573
Merged
auto-submit[bot] merged 201 commits intoflutter:masterfrom Dec 21, 2022
Merged
Add support for double tap and drag for text selection#109573auto-submit[bot] merged 201 commits intoflutter:masterfrom
auto-submit[bot] merged 201 commits intoflutter:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds support for double tap + drag, to select word by word when double tapping and then dragging the mouse.
This change also adds a new gesture recognizers that will be specifically useful for text selection:
TapAndDragGestureRecognizerThis recognizer makes use of a
_TapStatusTrackerMixinto keep track of the tap count.TextSelectionGestureDetectorno longer uses aTapGestureRecognizerorPanGestureRecognizer.TapUp,TapDown,TapCancel,onStart,onUpdate,onEnd, andonCancelare now handled by the new recognizer.Currently our text selection system does not support double tap + drag (selects word by word) and triple tap + drag (selects line by line). This PR adds support for this behavior by bundling the handling of tap up and tap down with a drag gesture recognizer and long press gesture recognizer. This helps us avoid having to pass state around to accomplish the same behavior. For example, this behavior could also be accomplished by having the TapGestureRecognizer.onTapDown callback, save the tap count, then this tap count can be used by the DragGestureRecognizer.onUpdate callback to determine if the selection should be updated character by character, word by word, or line by line. Some disadvantages of passing state around between gesture recognizers are that you can't accomplish this behavior in a classes initializer (Trying to build a default mapping of gesture recognizers for text selection https://github.com/Renzo-Olivares/flutter/blob/3dbffa3922c656e5c2f97fb6ff8d42b4573d152c/packages/flutter/lib/src/widgets/default_selection_gestures.dart#L24).
Will be handled in separate PR:
Selection area #104552
Fixes #99071, #64550, #23973
Pre-launch Checklist
///).