Skip to content

[iOS] Hover gesture reports wrong pointerType #3977

@AndreasHogstrom

Description

@AndreasHogstrom

Description

The hover gesture reports the wrong type of pointer.

The eventExtraData method of the hover handler uses UITouchTypePencil instead of the RNGH internal RNGestureHandlerStylus, which causes the enum mapping to become MOUSE instead.

https://github.com/software-mansion/react-native-gesture-handler/blob/v2.30.0/packages/react-native-gesture-handler/apple/Handlers/RNHoverHandler.m#L160

The same method also causes the pointer type to be reported as the same, whether using a stylus or a mouse. There doesn't seem to be a clear way of separating the types on iOS, but checking if zOffset property of UIHoverGestureRecognizer is > 0 might suffice?

https://developer.apple.com/documentation/uikit/uihovergesturerecognizer/4098402-zoffset?language=objc

Steps to reproduce

  1. Open Snack reproducer on an iOS device capable of stylus hover.
  2. Hover salmon coloured square with Stylus (e.g. Apple Pencil Pro).
  3. Tap the same area with the same Stylus.
  4. Notice Tap Pointer Type label indicates STYLUS, while Hover Pointer Type indicates MOUSE.

A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://snack.expo.dev/@andreashogstromnavigraph/rngh-hover-pointertype

Gesture Handler version

2.29.0

React Native version

0.83.0

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

New Architecture (Fabric)

Build type

None

Device

Real device

Device model

iPad Pro 13-inch (M4)

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions