Skip to content

Commit 0b969bb

Browse files
authored
Merge pull request #1627 from tom-un/user/tomun/fix-touch-pagexy-coordinates
Back port 1619 and 1288 to 0.68: Fix coordinates of touch.pageX/pageY coordinates when RCTRootView is not at the origin of the NSWindow
2 parents 260dbcd + 830ea70 commit 0b969bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

React/Base/RCTTouchHandler.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ - (void)_updateReactTouchAtIndex:(NSInteger)touchIndex
224224
#else // [TODO(macOS GH#774)
225225
NSEvent *nativeTouch = _nativeTouches[touchIndex];
226226
CGPoint location = nativeTouch.locationInWindow;
227-
CGPoint rootViewLocation = CGPointMake(location.x, CGRectGetHeight(self.view.window.frame) - location.y);
228-
CGPoint touchViewLocation = rootViewLocation;
227+
RCTAssert(_cachedRootView, @"We were unable to find a root view for the touch");
228+
CGPoint rootViewLocation = [_cachedRootView.window.contentView convertPoint:location toView:_cachedRootView];
229+
NSView *touchView = _touchViews[touchIndex];
230+
CGPoint touchViewLocation = [touchView convertPoint:location fromView:nil];
229231
#endif // ]TODO(macOS GH#774)
230232

231233
NSMutableDictionary *reactTouch = _reactTouches[touchIndex];

0 commit comments

Comments
 (0)