react-native-macos icon indicating copy to clipboard operation
react-native-macos copied to clipboard

Improved input handling

Open aleclarson opened this issue 6 years ago • 0 comments

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).

aleclarson avatar Feb 19 '19 18:02 aleclarson