-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Steps to reproduce
This is a follow up on the unresolved-but-closed issue: #137962
I'm experiencing the same issue implementing a touch-screen keyboard: the 18 (logical) px kTouchSlop constant causes typing at a reasonable (not fast) speed to be impractical. This is on a relatively "full size" touch keyboard with keys about 100 (L)px square.
TapGestureRecognizer (and also LongPressGestureRecognizer) do not allow configuration of a touch slop value. Other gestures (e.g. pan) do support enclosing a GestureDetector in a MediaQuery with a custom DeviceGestureSettings value specifying touch slop.
TapGestureRecognizer and LongPressGestureRecognizer both extend PrimaryPointerGestureRecognizer. PrimaryPointerGestureRecognizer does allow configuration of touch slop, but the extending Tap/LongPress recognizers don't expose it for configuration. I've had success creating my own gesture recognizer based on PrimaryPointerGestureRecognizer, differing only from TapGestureRecognizer in its ability to set touch slop.
In my case, when the slop is upgraded to 64px, the keyboard can be typed on at reasonable/fast speeds. When typing quickly, a user's touch will be less precise and drag more across keys.
Even outside the keyboard, it appears the entire application could benefit from a significantly larger touch slop. With 18px it requires fairly precise taps.
Expected results
Touch slop should be configurable on a per-application, per gesture-detector, or per-gesture-recognizer basis. TapGestureRecognizer and LongPressGestureRecognizer should support MediaQuery-based DeviceGestureSettings.
Actual results
Touch slop is hardcoded as kTouchSlop constant and cannot be modified. DeviceGestureSettings do not work on tap/longpress gestures.
Code sample
child: MediaQuery(
data: MediaQuery.of(context).copyWith(
gestureSettings: const DeviceGestureSettings(
touchSlop: 64,
),
),
child: GestureDetector(
onTap: widget.onTap,
Screenshots or Video
N/A
Logs
N/A
Flutter Doctor output
N/A