@@ -281,15 +281,20 @@ static PointerEvent CreatePointerEventFromActivePointer(
281281 UIView *rootComponentView)
282282{
283283 PointerEvent event = {};
284- #if !TARGET_OS_VISION
285284 event.pointerId = activePointer.identifier ;
286285 event.pointerType = PointerTypeCStringFromUITouchType (activePointer.touchType );
287286
288287 if (eventType == RCTPointerEventTypeCancel) {
289288 event.clientPoint = RCTPointFromCGPoint (CGPointZero);
289+ #if TARGET_OS_VISION
290+ event.screenPoint =
291+ RCTPointFromCGPoint ([rootComponentView convertPoint: CGPointZero
292+ toCoordinateSpace: rootComponentView.window.coordinateSpace]);
293+ #else
290294 event.screenPoint =
291295 RCTPointFromCGPoint ([rootComponentView convertPoint: CGPointZero
292296 toCoordinateSpace: rootComponentView.window.screen.coordinateSpace]);
297+ #endif
293298 event.offsetPoint = RCTPointFromCGPoint ([rootComponentView convertPoint: CGPointZero
294299 toView: activePointer.componentView]);
295300 } else {
@@ -330,7 +335,6 @@ static PointerEvent CreatePointerEventFromActivePointer(
330335 event.tangentialPressure = 0.0 ;
331336 event.twist = 0 ;
332337 event.isPrimary = activePointer.isPrimary ;
333- #endif
334338 return event;
335339}
336340
@@ -370,14 +374,18 @@ static void UpdateActivePointerWithUITouch(
370374 UIEvent *uiEvent,
371375 UIView *rootComponentView)
372376{
373- #if !TARGET_OS_VISION
374377 CGPoint location = [uiTouch locationInView: rootComponentView];
375378 UIView *hitTestedView = [rootComponentView hitTest: location withEvent: nil ];
376379 activePointer.componentView = FindClosestFabricManagedTouchableView (hitTestedView);
377380
378381 activePointer.clientPoint = [uiTouch locationInView: rootComponentView];
382+ #if TARGET_OS_VISION
383+ activePointer.screenPoint = [rootComponentView convertPoint: activePointer.clientPoint
384+ toCoordinateSpace: rootComponentView.window.coordinateSpace];
385+ #else
379386 activePointer.screenPoint = [rootComponentView convertPoint: activePointer.clientPoint
380387 toCoordinateSpace: rootComponentView.window.screen.coordinateSpace];
388+ #endif
381389 activePointer.offsetPoint = [uiTouch locationInView: activePointer.componentView];
382390
383391 activePointer.timestamp = uiTouch.timestamp ;
@@ -396,7 +404,6 @@ static void UpdateActivePointerWithUITouch(
396404 activePointer.button = ButtonMaskDiffToButton (activePointer.buttonMask , nextButtonMask);
397405 activePointer.buttonMask = nextButtonMask;
398406 activePointer.modifierFlags = uiEvent.modifierFlags ;
399- #endif
400407}
401408
402409/* *
@@ -743,12 +750,15 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer
743750 pointerId : (int )pointerId
744751 pointerType : (std::string)pointerType API_AVAILABLE(ios(13.0 ))
745752{
746- #if !TARGET_OS_VISION
747753 UIView *listenerView = recognizer.view ;
748754 CGPoint clientLocation = [recognizer locationInView: listenerView];
755+ #if TARGET_OS_VISION
756+ CGPoint screenLocation = [listenerView convertPoint: clientLocation
757+ toCoordinateSpace: listenerView.window.coordinateSpace];
758+ #else
749759 CGPoint screenLocation = [listenerView convertPoint: clientLocation
750760 toCoordinateSpace: listenerView.window.screen.coordinateSpace];
751-
761+ # endif
752762 UIView *targetView = [listenerView hitTest: clientLocation withEvent: nil ];
753763 targetView = FindClosestFabricManagedTouchableView (targetView);
754764
@@ -770,7 +780,6 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer
770780 eventEmitter->onPointerMove (event);
771781 }
772782 }
773- #endif
774783}
775784
776785@end
0 commit comments