[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
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 focused NSTextView
Emit mouseOut event when the mouse leaves the RCTWindow
Emit touchCancel event when a "touch" leaves the RCTWindow
Support mouseMove events (which can be coalesced)
Emit mouseMove event right after mouseUp events
Blur the focused NSTextView when clicking outside it
Support rightClick events
Add altKey, ctrlKey, metaKey, and shiftKey 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 to mouseOver (to align with browsers)
rename mouseLeave to mouseOut (to align with browsers)
In the future, I might implement the mouseEnter and mouseLeave events properly (using the JS event system).
Add the
RCTWindow
class that improves upon the current input handling logic.Users can opt-in by using
RCTWindow
in place ofNSWindow
. 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
eventsBlur the focused
NSTextView
when clicking outside itSupport
rightClick
eventsAdd
altKey
,ctrlKey
,metaKey
, andshiftKey
properties to JS mouse eventsUse
convertPoint:toView:
to compute the relative mouse locationIn the future, I might try updating
RCTTouchHandler
with the same logic thatRCTWindow
has. That's what I tried originally, but I ran into issues betweenNSGestureRecognizer
andNSTextView
.Other changes
mouseEnter
tomouseOver
(to align with browsers)mouseLeave
tomouseOut
(to align with browsers)In the future, I might implement the
mouseEnter
andmouseLeave
events properly (using the JS event system).