PointerDeviceKind and ui.PointerChange forwards-compatibility (#97350)
* PointerDeviceKind and ui.PointerChange forwards-compatibility * Add link to trackpad gestures issue * Add TODO
This commit is contained in:
@@ -21,6 +21,8 @@ int _synthesiseDownButtons(int buttons, PointerDeviceKind kind) {
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
return buttons == 0 ? kPrimaryButton : buttons;
|
||||
case PointerDeviceKind.unknown:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
// We have no information about the device but we know we never want
|
||||
// buttons to be 0 when the pointer is down.
|
||||
return buttons == 0 ? kPrimaryButton : buttons;
|
||||
@@ -207,6 +209,9 @@ class PointerEventConverter {
|
||||
radiusMax: radiusMax,
|
||||
embedderId: datum.embedderId,
|
||||
);
|
||||
default: // ignore: no_default_cases, to allow adding new pointer events to [ui.PointerChange]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
throw StateError('Unreachable');
|
||||
}
|
||||
case ui.PointerSignalKind.scroll:
|
||||
final Offset scrollDelta =
|
||||
|
||||
@@ -2108,6 +2108,8 @@ double computeHitSlop(PointerDeviceKind kind, DeviceGestureSettings? settings) {
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
case PointerDeviceKind.touch:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
return settings?.touchSlop ?? kTouchSlop;
|
||||
}
|
||||
}
|
||||
@@ -2121,6 +2123,8 @@ double computePanSlop(PointerDeviceKind kind, DeviceGestureSettings? settings) {
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
case PointerDeviceKind.touch:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
return settings?.panSlop ?? kPanSlop;
|
||||
}
|
||||
}
|
||||
@@ -2134,6 +2138,8 @@ double computeScaleSlop(PointerDeviceKind kind) {
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
case PointerDeviceKind.touch:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
return kScaleSlop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,6 +653,8 @@ class _AndroidMotionEventConverter {
|
||||
toolType = AndroidPointerProperties.kToolTypeEraser;
|
||||
break;
|
||||
case PointerDeviceKind.unknown:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
toolType = AndroidPointerProperties.kToolTypeUnknown;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1649,6 +1649,8 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
|
||||
break;
|
||||
case PointerDeviceKind.mouse:
|
||||
case PointerDeviceKind.unknown:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
_lastInteractionWasTouch = false;
|
||||
expectedMode = FocusHighlightMode.traditional;
|
||||
break;
|
||||
|
||||
@@ -668,6 +668,8 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
|
||||
case PointerDeviceKind.stylus:
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
return interactiveRect.contains(position);
|
||||
}
|
||||
}
|
||||
@@ -700,6 +702,8 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
|
||||
case PointerDeviceKind.stylus:
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
return _thumbRect!.contains(position);
|
||||
}
|
||||
}
|
||||
@@ -1936,6 +1940,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
case PointerDeviceKind.touch:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -1949,6 +1955,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
|
||||
case PointerDeviceKind.invertedStylus:
|
||||
case PointerDeviceKind.unknown:
|
||||
case PointerDeviceKind.touch:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1145,6 +1145,8 @@ class TextSelectionGestureDetectorBuilder {
|
||||
break;
|
||||
case PointerDeviceKind.touch:
|
||||
case PointerDeviceKind.unknown:
|
||||
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
|
||||
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
|
||||
// On macOS/iOS/iPadOS a touch tap places the cursor at the edge
|
||||
// of the word.
|
||||
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
|
||||
|
||||
Reference in New Issue
Block a user