-
Notifications
You must be signed in to change notification settings - Fork 428
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
Improved input handling #228
Open
aleclarson
wants to merge
12
commits into
master
Choose a base branch
from
window
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The "mouseEnter" event in browsers does not bubble, while "mouseOver" does.
aleclarson
force-pushed
the
window
branch
2 times, most recently
from
February 19, 2019 19:10
952a202
to
778cd07
Compare
ptmt
approved these changes
Feb 23, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that, thanks for a huge amount of effort!
aleclarson
force-pushed
the
window
branch
2 times, most recently
from
February 23, 2019 16:29
b347bbb
to
5a1de46
Compare
The "mouseLeave" event in browsers does not bubble, while "mouseOut" does.
By subclassing NSWindow and overriding the "sendEvent:" method, we can avoid using the NSGestureRecognizer class, which seems to cause issues with NSTextView event handling. The RCTWindow class reimplements input event handling, which solves the following issues: - Skip "touchStart" events that target a focused NSTextView - Emit "mouseOut" event when the mouse leaves the RCTWindow - Emit "touchCancel" when the mouse 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 "contextMenu" events - Add "altKey", "ctrlKey", "metaKey", and "shiftKey" properties to JS mouse events - Use "convertPoint:toView:" to compute the relative mouse location
These new calculations match the UIManager#measure method.
This was referenced Mar 14, 2019
The RCTRootContentView "hitTest:" method now flips the Y-axis of whatever point is passed to it, instead of relying on the caller to do it. Also, the `passThroughTouches` property of RCTRootView now works as expected.
This was referenced Apr 11, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).