Skip to content
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

Fix for bug where mouse coordinates are wrong #239

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions React/Base/RCTTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ - (void)_recordNewTouches:(NSSet<NSEvent *> *)touches

NSPoint touchLocation = [touch locationInWindow];

// adjust touchLocation if our view placed inside custom PopoverWindow
if ([[self.view window].className isEqualToString:@"_NSPopoverWindow"]) {
// adjust touchLocation if our view placed inside custom PopoverWindow
NSPoint rootOrigin = [self.view window].contentView.frame.origin;
touchLocation = NSMakePoint(touchLocation.x - rootOrigin.x, touchLocation.y - rootOrigin.y);
} else if (self.view.superview) {
// if our view has a superview, adjust the window coordinates to view coordinates.
touchLocation = [touch.window.contentView convertPoint:touchLocation toView:self.view.superview];
}

// TODO: get rid of explicit comparison
//
// Check if item is becoming first responder to delete touch
NSView *targetView = [self.view hitTest:touchLocation];

if (![targetView.className isEqualToString:@"RCTView"] &&
![targetView.className isEqualToString:@"RCTTextView"] &&
![targetView.className isEqualToString:@"RCTImageView"] &&
![targetView.className isEqualToString:@"ARTSurfaceView"]) {
self.state = NSGestureRecognizerStateEnded;
return;
// Find closest React-managed touchable view
while (targetView) {
if (targetView.reactTag) {
break;
}
targetView = targetView.superview;
}

NSNumber *reactTag = [self.view reactTagAtPoint:CGPointMake(touchLocation.x, touchLocation.y)];
Expand Down