-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Single tap on the previous selection should toggle the toolbar on iOS… #108913
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
Changes from all commits
795f61e
b43c5a2
11a9cae
72a5806
74df6b9
057d165
6c1b4d2
0ba1aee
fcf9ab5
237fd1f
9846b8e
a189254
ca6d610
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1657,6 +1657,19 @@ class TextSelectionGestureDetectorBuilder { | |
| && renderEditable.selection!.end >= textPosition.offset; | ||
| } | ||
|
|
||
| bool _tapWasOnSelection(Offset position) { | ||
| if (renderEditable.selection == null) { | ||
| return false; | ||
| } | ||
|
|
||
| final TextPosition textPosition = renderEditable.getPositionForPoint( | ||
| position, | ||
| ); | ||
|
|
||
| return renderEditable.selection!.start < textPosition.offset | ||
| && renderEditable.selection!.end > textPosition.offset; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this work if the selection is collapsed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talked offline about not handling The reason I didn't handle the |
||
| } | ||
|
|
||
| // Expand the selection to the given global position. | ||
| // | ||
| // Either base or extent will be moved to the last tapped position, whichever | ||
|
|
@@ -1887,13 +1900,15 @@ class TextSelectionGestureDetectorBuilder { | |
| case TargetPlatform.linux: | ||
| case TargetPlatform.macOS: | ||
| case TargetPlatform.windows: | ||
| editableText.hideToolbar(); | ||
| // On desktop platforms the selection is set on tap down. | ||
| if (_isShiftTapping) { | ||
| _isShiftTapping = false; | ||
| } | ||
| break; | ||
| case TargetPlatform.android: | ||
| case TargetPlatform.fuchsia: | ||
| editableText.hideToolbar(); | ||
| if (isShiftPressedValid) { | ||
| _isShiftTapping = true; | ||
| _extendSelection(details.globalPosition, SelectionChangedCause.tap); | ||
|
|
@@ -1927,7 +1942,16 @@ class TextSelectionGestureDetectorBuilder { | |
| case PointerDeviceKind.touch: | ||
| case PointerDeviceKind.unknown: | ||
| // On iOS/iPadOS a touch tap places the cursor at the edge of the word. | ||
| renderEditable.selectWordEdge(cause: SelectionChangedCause.tap); | ||
| final TextSelection previousSelection = editableText.textEditingValue.selection; | ||
| // If the tap was within the previous selection, then the selection should stay the same. | ||
| if (!_tapWasOnSelection(details.globalPosition)) { | ||
| renderEditable.selectWordEdge(cause: SelectionChangedCause.tap); | ||
| } | ||
| if (previousSelection == editableText.textEditingValue.selection && renderEditable.hasFocus) { | ||
| editableText.toggleToolbar(false); | ||
| } else { | ||
| editableText.hideToolbar(false); | ||
| } | ||
| break; | ||
| } | ||
| break; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.