Skip to content

kTouchSlop too low and not configurable (RE: kTouchSlop const needs to change from 18 to 64 for touches to feel responsive #137962) #154215

@tlty

Description

@tlty

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions