Commit cd0f15a
Add support for double tap and drag for text selection (#109573)
* Replace PanGestureRecognizer in TextSelection with TapAndDragGestureRecognizer
* add tracking of _DragState to new tap_and_drag recognizer and remove some legacy double tap code from text_selection.dart and add logs"
* add dragTapCount, a tap count that is persistent for an entire drag and is set to null on drag end vs the regular tap count which is reset on a timer
* basic double tap to drag functionality and add a local dragTapCount in text_selection.dart to use with the timer callback
* Add offsetFromOrigin and localOffsetFromOrigin to DragUpdateDetails similar to LongPressMoveUpdateDetails, eliminates the need to hold the state of lastDragStartDetails
* make a generic baselongpressgesturerecognizer
* Revert "make a generic baselongpressgesturerecognizer"
This reverts commit aad8f7433bd01e4cd016d527af832c3b1f15fac5.
* rename tap_and_drag to selection_recognizers
* add mixin for consecutivetap
* tap and long press gesture recognizer
* Revert "Revert "make a generic baselongpressgesturerecognizer""
This reverts commit 181350c36718f644eada3e45c1b7b5939f90a340.
* Revert "Revert "Revert "make a generic baselongpressgesturerecognizer"""
This reverts commit 4d69775967858dfd66dd9429e1713da598908a85.
* Add support for secondary button clicks on drag gesture recognizer and separate drag end and tap up callback
* get test running
* rename tapCount to consecutiveTapCount
* dispose timer properly
* add some comments to tests
* Add comments
* Make ConsecutiveTapMixin private and move logic to increment tap count into mixin
* stop tracking pointer when gesture is rejected and detect drags on touch devices
* onCancel for TapAndDrag
* have the TapAndDragGestureRecognizer handle tap downs and tap ups on touch and mouse devices
* add drag to move cursor for android and iOS, and pointer device kind to DragUpdateDetails
* get tests running
* refactor TapAndDragGestureRecognizer moving some logic into _check methods
* Handle cancel properly on TapAndDragGestureRecognizer, having both onTapCancel and onDragCancel, also fix tests
* Fix test mouse drag selects and cannot drag cursor, save _initialPosition based on dragStartBehavior (either on tapDown or dragStart)
* determine if drag has a sufficient global distance to accept and fix some cancel behavior, making _checkCancel clearer
* give up pointer on drag end
* properly stop tracking pointer, fixes test for right click on Apple and non-apple platforms
* clean up some comments from last commit
* remove drag on touch for now
* fix Can select text by dragging with a mouse due to dragStart only being fired on the first PointerMoveEvent, the previous pan gesture recognizer would fire both dragStart and dragUpdate
* Revert "fix Can select text by dragging with a mouse due to dragStart only being fired on the first PointerMoveEvent, the previous pan gesture recognizer would fire both dragStart and dragUpdate"
This reverts commit 124dc79bc3389672c76d7c014ce04edab297abc6.
* correctly use _initialPosition for checkStart and call _checkUpdate after _checkStart if localDelta is not zero
* updates
* fix double tap chains
* Add docs
* Address analyzer
* more analyzer, only issues left are with print statements
* add deadlineTimer to fix conflict with ForcePressGestureRecognizer
* Revert "add deadlineTimer to fix conflict with ForcePressGestureRecognizer"
This reverts commit 3b29ddfff4cde4845edd481ecefb789fea2a0781.
* remove unecessary changes to tests
* secondaryButton should not drag
* Revert "Revert "add deadlineTimer to fix conflict with ForcePressGestureRecognizer""
This reverts commit 0a008f029f5796acd48c17c1897c0b700d5ef3a7.
* updates
* Revert "updates"
This reverts commit 4803b8443a2b67f0b8d29e9a01f712dfcb0f588c.
* Revert "Revert "Revert "add deadlineTimer to fix conflict with ForcePressGestureRecognizer"""
This reverts commit 79251a7af88d5dbb1460a960afc77e65dea18bff.
* fix shift + tap + drag tests, this was happening because a double tap + drag was being registered and not a single tap, added a duration to pumpAndSettle to fix this
* remove TapAndLongPressGestureRecognizer
* fix cupertino text field tests related to shift + tap + drag
* deadline timer try 2
* more logs
* Should reset taps when tap cancel is called, and should wait until gesture is accepted to initiate a drag
* should clear _down and _up when gesture is rejected
* remove erroneous log
* fix selectable text double tap chains test
* dont restart timer until tap up
* reset consecutiveTapCount on drag end
* fix selectableText test
* fix material text field tests
* reject TapAndDragGestureRecognizer when it is neither a tap nor a drag
* remove prints
* clean up
* shift aware
* clean up
* fix cupertino test
* fix text field focus tests
* Add 100ms delay to cupertino test, to prevent a double tap
* clean up test comments
* add comment to test
* uncomment test
* remove longpress changes
* Fix drag on mobile
* remove debug
* Fix drag to move cursor on iOS
* left over from drag fix
* add tests for drag on touch devices
* add test for double tap + drag mouse devices
* add tests
* Fix bug where initialPosition was used before it was set
* Address some review comments and fix issue where if double tap was held too long then long press gesture recognizer would take over
* remove _isDoubleTap flag since it is no longer needed due to previous commit
* Add docs for onTapCancel and onDragCancel
* analyzer fixes
* Do not test selection handles on macOS, since macOS does not support touch
* Add assert for dragStartBehavior
* add double tap + drag tests to cupertino
* use kDoubleTapTimeout instead of const Duration(milliseconds: 300) for readability
* analyzer issues
* update docs
* update more docs
* address comments
* more doc updates
* fix docs
* unused import
* fix docs
* Add more tests
* Add more tests and reject a tap up if we have exceeded the tap tolerance
* updates
* Address comments
* fix test naming
* update documentation
* move selection_recognizers to selection_gestures
* fix analyzer
* fix analyzer
* keysPressedOnDown instead of isShiftPressed
* update docs
* update docs
* Add drag update throttle to TapAndDragGestureRecognizer
* update comments
* missed from merge
* Replace _ConsecutiveTapMixin with _TapStatusTrackerMixin
* updates
* correctly cancel tap when when past tap tolerance with new implementation
* Should call tap and drag cancel if we are giving up a pointer without succesfully tracking a PointerUpEvent
* comments
* move pastTapTolerance to tap tracker
* move pastTapTolerance to tap tracker
* clean up check for nulls and remove use of consecutiveTapCountWhileDragging
* move call to super.acceptGesture to top
* remove print
* clean up
* Fix tests where both PanGestureRecognizer and TapAndDragGestureRecognizer lost
* clean up
* _GestureState -> _DragState
* more docs clean up
* more clean up
* Add onSecondaryTapCancel
* Add docs
* more docs
* Fix broken isPointerAllowed when attempting a right click drag - the _initialButtons is never reset
* revert debug flag
* make primaryPointer private
* Add support for upper count limit in TapAndDragGestureRecognizer, the tap counter should not be allowed to grow infinitely unless that is desired
* fix analyzer
* Use new TapDrag details objects and callbacks
* clean up docs
* clean up and add test for upperLimit
* Add docs for TapAndDragGestureRecognizer and remove some ambiguity of onStart onUpdate and onEnd parameters
* Address review comments
* analyzer fixes
* Call cancel before rejecting the gesture so we can still access _initialButtons
* Recognizer should reject any pointer differing from the original
* Revert "Recognizer should reject any pointer differing from the original"
This reverts commit afd9807480bd11e119bdd2b7d520631511973bab.
* Address reviewer comments
* Correct cancel behavior
* Fix consecutive tap + drag because _dragStart state was not being set when consecutive tap is greater than one
* Add more tests
* Add documentation on behavior with TapGestureRecognizer and DragGestureRecognizer
* more docs
* more docs
* remove comments
* updates
* fix multiple pointer behavior
* only handle the primary pointer
* Clean up dangerous assumptions in gesture details objects
* forgot from rebase
* update docs
* updates
* Clean up some redundant code
* remove whitespace
* fix tests as a result of #115849
* update test docs
* Fix same test from last commit for material variants
* More clean up of redundant code and update docs
* Clean up didStopTrackingLastPointer and untie TapAndDragGestureRecognizer cancel behavior from TapStatusTrackerMixin.currentUp state
* untie pastTapTolerance
* updates
* Add slopTolerance
* update docs
* Have secondary tap handled by TapGestureRecognizer
* update docs
* fix analyzer and address comments
* Add more docs
* Update cancel behavior tol not call on tap cancel when a drag has been accepted
* Change cancel behavior to only cancel if the tap down callback has been sent and merge tapcancel and dragcancel
* update docs;
* Rename selection_gestures to tap_and_drag_gestures
* Address some reviewer comments
* make deadline and slopTolerance private
* updates
* updates
* Address review comments
* remove _initialButtons
* fix docs
* trackTrap -> trackTap
* fix analyzer
* Add test to verify that tap up is called when recognizer accepts before handleEvent is called
* implement Diagnosticable for Details objects;
* sentTapDown == wonArenaForPrimaryPointer, so the implementation now only uses sentTapDown
* Count user tap up immediately and do not wait to win the arena
* Do not need to call super from TapAndDragGestureRecognizer.acceptGesture anymore because mixin implementation is gone
* Do not start selection drag on Android, iOS, and Fuchshsia touch devices if renderEditable does not have focus, this fixes many scubas
* Address reviewer comments
* fix test
* TapAndDragGestureRecognizer should wait for other recognizer to lose before winning the arena
* Address review comments
* Dont check for drag if the start was already found
* Only check for a drag if it has not already been found"
* fix from rebase
Co-authored-by: Renzo Olivares <roliv@google.com>1 parent 014b8f7 commit cd0f15a
File tree
15 files changed
+2635
-215
lines changed- packages/flutter
- lib
- src
- cupertino
- gestures
- material
- widgets
- test
- cupertino
- gestures
- material
- widgets
15 files changed
+2635
-215
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| |||
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | | - | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| 200 | + | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
| 206 | + | |
203 | 207 | | |
204 | 208 | | |
205 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| 129 | + | |
127 | 130 | | |
128 | 131 | | |
| 132 | + | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
| |||
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
| 147 | + | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
| |||
149 | 155 | | |
150 | 156 | | |
151 | 157 | | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| 162 | + | |
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
360 | 364 | | |
361 | 365 | | |
362 | 366 | | |
| 367 | + | |
363 | 368 | | |
364 | 369 | | |
| 370 | + | |
365 | 371 | | |
366 | 372 | | |
367 | 373 | | |
| |||
378 | 384 | | |
379 | 385 | | |
380 | 386 | | |
| 387 | + | |
381 | 388 | | |
382 | 389 | | |
| 390 | + | |
383 | 391 | | |
384 | 392 | | |
385 | 393 | | |
| |||
411 | 419 | | |
412 | 420 | | |
413 | 421 | | |
| 422 | + | |
414 | 423 | | |
415 | 424 | | |
| 425 | + | |
416 | 426 | | |
417 | 427 | | |
418 | 428 | | |
| |||
428 | 438 | | |
429 | 439 | | |
430 | 440 | | |
| 441 | + | |
431 | 442 | | |
432 | 443 | | |
| 444 | + | |
433 | 445 | | |
434 | 446 | | |
435 | 447 | | |
| |||
444 | 456 | | |
445 | 457 | | |
446 | 458 | | |
| 459 | + | |
447 | 460 | | |
448 | 461 | | |
| 462 | + | |
449 | 463 | | |
450 | 464 | | |
451 | 465 | | |
| |||
462 | 476 | | |
463 | 477 | | |
464 | 478 | | |
| 479 | + | |
465 | 480 | | |
466 | 481 | | |
| 482 | + | |
467 | 483 | | |
468 | 484 | | |
469 | 485 | | |
| |||
482 | 498 | | |
483 | 499 | | |
484 | 500 | | |
| 501 | + | |
485 | 502 | | |
486 | 503 | | |
| 504 | + | |
487 | 505 | | |
488 | 506 | | |
489 | 507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
0 commit comments