discussions-and-proposals icon indicating copy to clipboard operation
discussions-and-proposals copied to clipboard

onMouseEnter/onMouseLeave for genereric Views 📱🖱️

Open gomes042 opened this issue 3 years ago • 5 comments

Introduction

You can connect mouse to mobile devices via USB or Bluetooth but while working with generic view, hover events for that are not exposed.

Example of discord app's usage for hover events:

Reference

Android OnHoverListener: https://developer.android.com/reference/android/view/View.OnHoverListener

IOS UIHoverGestureRecognizer: https://developer.apple.com/documentation/uikit/uihovergesturerecognizer

gomes042 avatar Jul 13 '22 18:07 gomes042

+1 and it's not just a mouse this would be useful for:

  • Many Android devices have pens with some form of "air hover" feature, e.g. the Samsung Galaxy s-pen is very widely used, and I believe there are others too (e.g. high-end tablets marketed at digital artists?).
  • I believe the Apple Pencil (and connected mouse) does something similar on iOS? iOS has UIHoverGestureRecognizer like Android's View.OnHoverListener you mentioned in the issue.

I believe these all trigger the same hover events as a connected mouse. Many pure-native apps support hover events perfectly for these.

AlanSl avatar Jul 28 '22 10:07 AlanSl

+1 and it's not just a mouse this would be useful for:

  • Many Android devices have pens with some form of "air hover" feature, e.g. the Samsung Galaxy s-pen is very widely used, and I believe there are others too (e.g. high-end tablets marketed at digital artists?).
  • I believe the Apple Pencil (and connected mouse) does something similar on iOS? iOS has UIHoverGestureRecognizer like Android's View.OnHoverListener you mentioned in the issue.

I believe these all trigger the same hover events as a connected mouse. Many pure-native apps support hover events perfectly for these.

Excellent point. Thanks for adding to the discussion!

gomes042 avatar Jul 28 '22 15:07 gomes042

Looking at the react-native code I found that this kind of pointer event seems to be under development and we will get there soon.

https://github.com/facebook/react-native/commit/6e5cefe604786c1883ca09febee0792af7ce1b34

gomes042 avatar Jul 30 '22 19:07 gomes042

Btw, seems @lunaleaps is actively working on it... Thank you a lot ❤️

image

https://github.com/facebook/react-native/commits?author=lunaleaps

gomes042 avatar Aug 16 '22 17:08 gomes042

@vincentriemer and I are working on implementing the PointerEvent spec and have some coarse implementation of it. You can opt into it using ReactFeatureFlag dispatchPointerEvents on Android, there's an equivalent flag in iOS.

lunaleaps avatar Aug 16 '22 17:08 lunaleaps

https://reactnative.dev/blog/2022/12/13/pointer-events-in-react-native

gomes042 avatar Dec 22 '22 03:12 gomes042

@runtothedoor Let us know if you end up trying it and have any thoughts: https://github.com/react-native-community/discussions-and-proposals/discussions/557

I'll close this and we can continue discussion there.

lunaleaps avatar Dec 23 '22 00:12 lunaleaps