-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cursor/Mouse API #9454
Comments
Apologies, I didn't realize this at the time but:
|
Actually, apologies, I, on the other hand, am looking for a |
Mouse hover support is under-documented today (tracked by microsoft/react-native-windows-samples#541). Can you look at the discussion there and in linked issues and see if your needs are met? If not, go ahead and reopen your issue. |
Admittedly, I am unsure whether this solves my problem or not due to the undocumented nature of things currently. However, after reading through the threads and reading through the In particular, while my outlined |
@dedavis6797 can you take a look at this and incorporate any requests into your future spec? |
@dedavis6797 Do you think this will make 0.69 or should it be moved to 0.70? |
onMouseMove do you have an estimate of when it will be implemented? |
There's these:
There's enough unity between the various RN platforms at this point that we'd prefer something here for all platforms, not just Windows. I was curious how react-native-web does this and found this: https://necolas.github.io/react-native-web/docs/interactions/#responderevent-props-api You can also see where things might be going for alignment between React DOM and React Native with this thread: react-native-community/discussions-and-proposals#496 |
@chrisglein, PanResponder does not meet my use case. The input and output events of both return the data I need, but neither onHoverIn nor onHoverOut operate by capturing mouse movements in the component, it has the same properties as onMouseEnter and onMouseLeave, which return the following data {
altKey: false
button: -1
ctrlKey: false
force: 0.5
identifier: 0
isBarrelButtonPressed: false
isEraser: false
isHorizontalScrollWheel: false
isLeftButton: false
isMiddleButton: false
isRightButton: false
locationX: 698,998
locationY: 2.98119
pageX: 698,998
pageY: 2.98119
pointerType: "Mouse"
shiftKey: false
target: 47
timestamp: 342842796
} but I need events that capture the synchronous movement of the mouse, I have tried some native implementations, but without success, since implementing this with synchronous methods could make it blocking |
For reference, the ways that the native stack accomplishes things like smooth scrolling that track the finger is by doing them on the composition thread itself. Even for the native controls, they avoid calling back up to the UI thread. To get the best experience here, you wouldn't want the many-layered call back up to JavaScript. You can read more about how that's done here: https://learn.microsoft.com/en-us/windows/uwp/composition/input-driven-animations |
the Button element of react-native-xaml always triggers new events when moving the mouse but almost all of them are null, through the onPointerMoved method, it's not much but it already solves a lot of problems, mainly in video players |
Summary
Hi! I'd love to see a
IMouseProps
logic very similar to the existingIKeyboardProps
or some other way to gain access to a mouse's location.While this API could differ in many ways, one idea is to add props, like
IKeyboardProps
such as:Which maps to a very similar API to the web's API
Motivation
I'm working on a comprehensive UI component library for React Native that supports RNW.
As part of this UI component library, I'd love to have access to a mouse's cursor location in order to do the "Smart Triangle" calculation that's so common for right-clicked menus, such as this:
submenusafetriangle3.mp4
I'm certain there are many other candidates for UI experiences that can only be done with a mouse API of some kind
Basic Example
Open Questions
Is this unique to Windows?
It may not be, since Android and iOS also seem to have cursors in some capacity as well
The text was updated successfully, but these errors were encountered: