Unverified Commit 39fa0117 authored by Renzo Olivares's avatar Renzo Olivares Committed by GitHub

Revert "Add support for double tap and drag for text selection (#109573)" (#117497)

This reverts commit cd0f15a7.
Co-authored-by: 's avatarRenzo Olivares <roliv@google.com>
parent 2931e50c
......@@ -102,7 +102,7 @@ class _CupertinoTextFieldSelectionGestureDetectorBuilder extends TextSelectionGe
final _CupertinoTextFieldState _state;
@override
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
// Because TextSelectionGestureDetector listens to taps that happen on
// widgets in front of it, tapping the clear button will also trigger
// this handler. If the clear button widget recognizes the up event,
......@@ -120,7 +120,7 @@ class _CupertinoTextFieldSelectionGestureDetectorBuilder extends TextSelectionGe
}
@override
void onDragSelectionEnd(TapDragEndDetails details) {
void onDragSelectionEnd(DragEndDetails details) {
_state._requestKeyboard();
}
}
......
......@@ -109,12 +109,10 @@ class DragStartDetails {
String toString() => '${objectRuntimeType(this, 'DragStartDetails')}($globalPosition)';
}
/// {@template flutter.gestures.dragdetails.GestureDragStartCallback}
/// Signature for when a pointer has contacted the screen and has begun to move.
///
/// The `details` object provides the position of the touch when it first
/// touched the surface.
/// {@endtemplate}
///
/// See [DragGestureRecognizer.onStart].
typedef GestureDragStartCallback = void Function(DragStartDetails details);
......@@ -128,7 +126,7 @@ typedef GestureDragStartCallback = void Function(DragStartDetails details);
/// * [DragStartDetails], the details for [GestureDragStartCallback].
/// * [DragEndDetails], the details for [GestureDragEndCallback].
class DragUpdateDetails {
/// Creates details for a [GestureDragUpdateCallback].
/// Creates details for a [DragUpdateDetails].
///
/// The [delta] argument must not be null.
///
......@@ -197,13 +195,11 @@ class DragUpdateDetails {
String toString() => '${objectRuntimeType(this, 'DragUpdateDetails')}($delta)';
}
/// {@template flutter.gestures.dragdetails.GestureDragUpdateCallback}
/// Signature for when a pointer that is in contact with the screen and moving
/// has moved again.
///
/// The `details` object provides the position of the touch and the distance it
/// has traveled since the last update.
/// {@endtemplate}
///
/// See [DragGestureRecognizer.onUpdate].
typedef GestureDragUpdateCallback = void Function(DragUpdateDetails details);
......
......@@ -26,13 +26,11 @@ enum _DragState {
accepted,
}
/// {@template flutter.gestures.monodrag.GestureDragEndCallback}
/// Signature for when a pointer that was previously in contact with the screen
/// and moving is no longer in contact with the screen.
///
/// The velocity at which the pointer was moving when it stopped contacting
/// the screen is available in the `details`.
/// {@endtemplate}
///
/// Used by [DragGestureRecognizer.onEnd].
typedef GestureDragEndCallback = void Function(DragEndDetails details);
......@@ -126,10 +124,8 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
/// * [DragDownDetails], which is passed as an argument to this callback.
GestureDragDownCallback? onDown;
/// {@template flutter.gestures.monodrag.DragGestureRecognizer.onStart}
/// A pointer has contacted the screen with a primary button and has begun to
/// move.
/// {@endtemplate}
///
/// The position of the pointer is provided in the callback's `details`
/// argument, which is a [DragStartDetails] object. The [dragStartBehavior]
......@@ -141,10 +137,8 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
/// * [DragStartDetails], which is passed as an argument to this callback.
GestureDragStartCallback? onStart;
/// {@template flutter.gestures.monodrag.DragGestureRecognizer.onUpdate}
/// A pointer that is in contact with the screen with a primary button and
/// moving has moved again.
/// {@endtemplate}
///
/// The distance traveled by the pointer since the last update is provided in
/// the callback's `details` argument, which is a [DragUpdateDetails] object.
......@@ -155,11 +149,9 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
/// * [DragUpdateDetails], which is passed as an argument to this callback.
GestureDragUpdateCallback? onUpdate;
/// {@template flutter.gestures.monodrag.DragGestureRecognizer.onEnd}
/// A pointer that was previously in contact with the screen with a primary
/// button and moving is no longer in contact with the screen and was moving
/// at a specific velocity when it stopped contacting the screen.
/// {@endtemplate}
///
/// The velocity is provided in the callback's `details` argument, which is a
/// [DragEndDetails] object.
......
......@@ -45,13 +45,11 @@ class TapDownDetails {
final Offset localPosition;
}
/// {@template flutter.gestures.tap.GestureTapDownCallback}
/// Signature for when a pointer that might cause a tap has contacted the
/// screen.
///
/// The position at which the pointer contacted the screen is available in the
/// `details`.
/// {@endtemplate}
///
/// See also:
///
......@@ -84,13 +82,11 @@ class TapUpDetails {
final PointerDeviceKind kind;
}
/// {@template flutter.gestures.tap.GestureTapUpCallback}
/// Signature for when a pointer that will trigger a tap has stopped contacting
/// the screen.
///
/// The position at which the pointer stopped contacting the screen is available
/// in the `details`.
/// {@endtemplate}
///
/// See also:
///
......@@ -364,10 +360,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
TapGestureRecognizer({ super.debugOwner, super.supportedDevices });
/// {@template flutter.gestures.tap.TapGestureRecognizer.onTapDown}
/// A pointer has contacted the screen at a particular location with a primary
/// button, which might be the start of a tap.
/// {@endtemplate}
///
/// This triggers after the down event, once a short timeout ([deadline]) has
/// elapsed, or once the gestures has won the arena, whichever comes first.
......@@ -384,10 +378,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// * [GestureDetector.onTapDown], which exposes this callback.
GestureTapDownCallback? onTapDown;
/// {@template flutter.gestures.tap.TapGestureRecognizer.onTapUp}
/// A pointer has stopped contacting the screen at a particular location,
/// which is recognized as a tap of a primary button.
/// {@endtemplate}
///
/// This triggers on the up event, if the recognizer wins the arena with it
/// or has previously won, immediately followed by [onTap].
......@@ -419,10 +411,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// * [GestureDetector.onTap], which exposes this callback.
GestureTapCallback? onTap;
/// {@template flutter.gestures.tap.TapGestureRecognizer.onTapCancel}
/// A pointer that previously triggered [onTapDown] will not end up causing
/// a tap.
/// {@endtemplate}
///
/// This triggers once the gesture loses the arena if [onTapDown] has
/// previously been triggered.
......@@ -438,10 +428,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// * [GestureDetector.onTapCancel], which exposes this callback.
GestureTapCancelCallback? onTapCancel;
/// {@template flutter.gestures.tap.TapGestureRecognizer.onSecondaryTap}
/// A pointer has stopped contacting the screen, which is recognized as a tap
/// of a secondary button.
/// {@endtemplate}
///
/// This triggers on the up event, if the recognizer wins the arena with it or
/// has previously won, immediately following [onSecondaryTapUp].
......@@ -456,10 +444,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// * [GestureDetector.onSecondaryTap], which exposes this callback.
GestureTapCallback? onSecondaryTap;
/// {@template flutter.gestures.tap.TapGestureRecognizer.onSecondaryTapDown}
/// A pointer has contacted the screen at a particular location with a
/// secondary button, which might be the start of a secondary tap.
/// {@endtemplate}
///
/// This triggers after the down event, once a short timeout ([deadline]) has
/// elapsed, or once the gestures has won the arena, whichever comes first.
......@@ -476,10 +462,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// * [GestureDetector.onSecondaryTapDown], which exposes this callback.
GestureTapDownCallback? onSecondaryTapDown;
/// {@template flutter.gestures.tap.TapGestureRecognizer.onSecondaryTapUp}
/// A pointer has stopped contacting the screen at a particular location,
/// which is recognized as a tap of a secondary button.
/// {@endtemplate}
///
/// This triggers on the up event if the recognizer wins the arena with it
/// or has previously won.
......@@ -498,10 +482,8 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
/// * [GestureDetector.onSecondaryTapUp], which exposes this callback.
GestureTapUpCallback? onSecondaryTapUp;
/// {@template flutter.gestures.tap.TapGestureRecognizer.onSecondaryTapCancel}
/// A pointer that previously triggered [onSecondaryTapDown] will not end up
/// causing a tap.
/// {@endtemplate}
///
/// This triggers once the gesture loses the arena if [onSecondaryTapDown]
/// has previously been triggered.
......
......@@ -85,7 +85,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
}
@override
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
editableText.hideToolbar();
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
......
......@@ -65,7 +65,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
}
@override
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
super.onSingleTapUp(details);
_state._requestKeyboard();
_state.widget.onTap?.call();
......
......@@ -135,7 +135,6 @@ export 'src/widgets/spacer.dart';
export 'src/widgets/spell_check.dart';
export 'src/widgets/status_transitions.dart';
export 'src/widgets/table.dart';
export 'src/widgets/tap_and_drag_gestures.dart';
export 'src/widgets/tap_region.dart';
export 'src/widgets/text.dart';
export 'src/widgets/text_editing_intents.dart';
......
......@@ -313,6 +313,7 @@ void main() {
tester.route(down1);
expect(tapsRecognized, 0);
tester.route(up2);
expect(tapsRecognized, 0);
GestureBinding.instance.gestureArena.sweep(2);
......
......@@ -196,7 +196,7 @@ void main() {
final TestGesture gesture = await tester.startGesture(textFieldStart, kind: PointerDeviceKind.mouse);
await tester.pump(const Duration(seconds: 2));
await gesture.up();
await tester.pumpAndSettle(kDoubleTapTimeout);
await tester.pumpAndSettle();
final FlutterError error = tester.takeException() as FlutterError;
expect(
......@@ -3907,7 +3907,6 @@ void main() {
expect(find.byType(CupertinoButton), findsNWidgets(1));
// Double tap selecting the same word somewhere else is fine.
await tester.pumpAndSettle(kDoubleTapTimeout);
await tester.tapAt(selectableTextStart + const Offset(10.0, 5.0));
await tester.pump(const Duration(milliseconds: 50));
// First tap moved the cursor.
......@@ -3929,7 +3928,6 @@ void main() {
editableTextState.hideToolbar();
await tester.pumpAndSettle();
await tester.pumpAndSettle(kDoubleTapTimeout);
await tester.tapAt(selectableTextStart + const Offset(150.0, 5.0));
await tester.pump(const Duration(milliseconds: 50));
// First tap moved the cursor.
......
......@@ -25,16 +25,16 @@ void main() {
late int dragEndCount;
const Offset forcePressOffset = Offset(400.0, 50.0);
void handleTapDown(TapDragDownDetails details) { tapCount++; }
void handleSingleTapUp(TapDragUpDetails details) { singleTapUpCount++; }
void handleTapDown(TapDownDetails details) { tapCount++; }
void handleSingleTapUp(TapUpDetails details) { singleTapUpCount++; }
void handleSingleTapCancel() { singleTapCancelCount++; }
void handleSingleLongTapStart(LongPressStartDetails details) { singleLongTapStartCount++; }
void handleDoubleTapDown(TapDragDownDetails details) { doubleTapDownCount++; }
void handleDoubleTapDown(TapDownDetails details) { doubleTapDownCount++; }
void handleForcePressStart(ForcePressDetails details) { forcePressStartCount++; }
void handleForcePressEnd(ForcePressDetails details) { forcePressEndCount++; }
void handleDragSelectionStart(TapDragStartDetails details) { dragStartCount++; }
void handleDragSelectionUpdate(TapDragUpdateDetails details) { dragUpdateCount++; }
void handleDragSelectionEnd(TapDragEndDetails details) { dragEndCount++; }
void handleDragSelectionStart(DragStartDetails details) { dragStartCount++; }
void handleDragSelectionUpdate(DragStartDetails _, DragUpdateDetails details) { dragUpdateCount++; }
void handleDragSelectionEnd(DragEndDetails details) { dragEndCount++; }
setUp(() {
tapCount = 0;
......@@ -173,12 +173,7 @@ void main() {
await gesture.moveBy(const Offset(100, 100));
await tester.pump();
expect(singleTapUpCount, 0);
// Before the move to TapAndDragGestureRecognizer the tapCount was 0 because the
// TapGestureRecognizer rejected itself when the initial pointer moved past a certain
// threshold. With TapAndDragGestureRecognizer, we have two thresholds, a normal tap
// threshold, and a drag threshold, so it is possible for the tap count to increase
// even though the original pointer has moved beyond the tap threshold.
expect(tapCount, 1);
expect(tapCount, 0);
expect(singleTapCancelCount, 0);
expect(doubleTapDownCount, 0);
expect(singleLongTapStartCount, 0);
......@@ -186,7 +181,7 @@ void main() {
await gesture.up();
// Nothing else happens on up.
expect(singleTapUpCount, 0);
expect(tapCount, 1);
expect(tapCount, 0);
expect(singleTapCancelCount, 0);
expect(doubleTapDownCount, 0);
expect(singleLongTapStartCount, 0);
......@@ -200,7 +195,7 @@ void main() {
await tester.pump();
expect(singleTapUpCount, 0);
expect(tapCount, 1);
expect(singleTapCancelCount, 0);
expect(singleTapCancelCount, 1);
expect(doubleTapDownCount, 0);
expect(singleLongTapStartCount, 0);
});
......@@ -375,7 +370,7 @@ void main() {
expect(singleLongTapStartCount, 0);
});
testWidgets('a touch drag is recognized for text selection', (WidgetTester tester) async {
testWidgets('a touch drag is not recognized for text selection', (WidgetTester tester) async {
await pumpGestureDetector(tester);
final int pointerValue = tester.nextPointer;
......@@ -389,12 +384,11 @@ void main() {
await gesture.up();
await tester.pumpAndSettle();
expect(tapCount, 1);
expect(tapCount, 0);
expect(singleTapUpCount, 0);
expect(singleTapCancelCount, 0);
expect(dragStartCount, 1);
expect(dragUpdateCount, 1);
expect(dragEndCount, 1);
expect(dragStartCount, 0);
expect(dragUpdateCount, 0);
expect(dragEndCount, 0);
});
testWidgets('a mouse drag is recognized for text selection', (WidgetTester tester) async {
......@@ -412,11 +406,8 @@ void main() {
await gesture.up();
await tester.pumpAndSettle();
// The tap and drag gesture recognizer will detect the tap down, but not the tap up.
expect(tapCount, 1);
expect(singleTapCancelCount, 0);
expect(tapCount, 0);
expect(singleTapUpCount, 0);
expect(dragStartCount, 1);
expect(dragUpdateCount, 1);
expect(dragEndCount, 1);
......@@ -437,11 +428,6 @@ void main() {
await gesture.up();
await tester.pumpAndSettle();
// The tap and drag gesture recognizer will detect the tap down, but not the tap up.
expect(tapCount, 1);
expect(singleTapCancelCount, 0);
expect(singleTapUpCount, 0);
expect(dragStartCount, 1);
expect(dragUpdateCount, 1);
expect(dragEndCount, 1);
......@@ -760,18 +746,12 @@ void main() {
final Offset position = textOffsetToPosition(tester, 4);
await tester.tapAt(position);
// Don't do a double tap drag.
await tester.pump(const Duration(milliseconds: 300));
await tester.pump();
expect(controller.selection.isCollapsed, isTrue);
expect(controller.selection.baseOffset, 4);
final TestGesture gesture = await tester.startGesture(position, kind: PointerDeviceKind.mouse);
// Checking that double-tap was not registered.
expect(controller.selection.isCollapsed, isTrue);
expect(controller.selection.baseOffset, 4);
addTearDown(gesture.removePointer);
await tester.pump();
await gesture.moveTo(textOffsetToPosition(tester, 7));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment