react-native-macos
react-native-macos copied to clipboard
Improved input handling
Add the RCTWindow
class that improves upon the current input handling logic.
Users can opt-in by using RCTWindow
in place of NSWindow
. If they don't, they'll continue to use the (flawed) RCTTouchHandler
logic.
Event handling in RCTWindow
is different in the following ways:
-
Skip
touchStart
events that target a focusedNSTextView
-
Emit
mouseOut
event when the mouse leaves theRCTWindow
-
Emit
touchCancel
event when a "touch" leaves theRCTWindow
-
Support
mouseMove
events (which can be coalesced) -
Emit
mouseMove
event right aftermouseUp
events -
Blur the focused
NSTextView
when clicking outside it -
Support
rightClick
events -
Add
altKey
,ctrlKey
,metaKey
, andshiftKey
properties to JS mouse events -
Use
convertPoint:toView:
to compute the relative mouse location
In the future, I might try updating RCTTouchHandler
with the same logic that RCTWindow
has. That's what I tried originally, but I ran into issues between NSGestureRecognizer
and NSTextView
.
Other changes
- rename
mouseEnter
tomouseOver
(to align with browsers) - rename
mouseLeave
tomouseOut
(to align with browsers)
In the future, I might implement the mouseEnter
and mouseLeave
events properly (using the JS event system).