@@ -281,15 +281,20 @@ static PointerEvent CreatePointerEventFromActivePointer(
281
281
UIView *rootComponentView)
282
282
{
283
283
PointerEvent event = {};
284
- #if !TARGET_OS_VISION
285
284
event.pointerId = activePointer.identifier ;
286
285
event.pointerType = PointerTypeCStringFromUITouchType (activePointer.touchType );
287
286
288
287
if (eventType == RCTPointerEventTypeCancel) {
289
288
event.clientPoint = RCTPointFromCGPoint (CGPointZero);
289
+ #if TARGET_OS_VISION
290
+ event.screenPoint =
291
+ RCTPointFromCGPoint ([rootComponentView convertPoint: CGPointZero
292
+ toCoordinateSpace: rootComponentView.window.coordinateSpace]);
293
+ #else
290
294
event.screenPoint =
291
295
RCTPointFromCGPoint ([rootComponentView convertPoint: CGPointZero
292
296
toCoordinateSpace: rootComponentView.window.screen.coordinateSpace]);
297
+ #endif
293
298
event.offsetPoint = RCTPointFromCGPoint ([rootComponentView convertPoint: CGPointZero
294
299
toView: activePointer.componentView]);
295
300
} else {
@@ -330,7 +335,6 @@ static PointerEvent CreatePointerEventFromActivePointer(
330
335
event.tangentialPressure = 0.0 ;
331
336
event.twist = 0 ;
332
337
event.isPrimary = activePointer.isPrimary ;
333
- #endif
334
338
return event;
335
339
}
336
340
@@ -370,14 +374,18 @@ static void UpdateActivePointerWithUITouch(
370
374
UIEvent *uiEvent,
371
375
UIView *rootComponentView)
372
376
{
373
- #if !TARGET_OS_VISION
374
377
CGPoint location = [uiTouch locationInView: rootComponentView];
375
378
UIView *hitTestedView = [rootComponentView hitTest: location withEvent: nil ];
376
379
activePointer.componentView = FindClosestFabricManagedTouchableView (hitTestedView);
377
380
378
381
activePointer.clientPoint = [uiTouch locationInView: rootComponentView];
382
+ #if TARGET_OS_VISION
383
+ activePointer.screenPoint = [rootComponentView convertPoint: activePointer.clientPoint
384
+ toCoordinateSpace: rootComponentView.window.coordinateSpace];
385
+ #else
379
386
activePointer.screenPoint = [rootComponentView convertPoint: activePointer.clientPoint
380
387
toCoordinateSpace: rootComponentView.window.screen.coordinateSpace];
388
+ #endif
381
389
activePointer.offsetPoint = [uiTouch locationInView: activePointer.componentView];
382
390
383
391
activePointer.timestamp = uiTouch.timestamp ;
@@ -396,7 +404,6 @@ static void UpdateActivePointerWithUITouch(
396
404
activePointer.button = ButtonMaskDiffToButton (activePointer.buttonMask , nextButtonMask);
397
405
activePointer.buttonMask = nextButtonMask;
398
406
activePointer.modifierFlags = uiEvent.modifierFlags ;
399
- #endif
400
407
}
401
408
402
409
/* *
@@ -743,12 +750,15 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer
743
750
pointerId : (int )pointerId
744
751
pointerType : (std::string)pointerType API_AVAILABLE(ios(13.0 ))
745
752
{
746
- #if !TARGET_OS_VISION
747
753
UIView *listenerView = recognizer.view ;
748
754
CGPoint clientLocation = [recognizer locationInView: listenerView];
755
+ #if TARGET_OS_VISION
756
+ CGPoint screenLocation = [listenerView convertPoint: clientLocation
757
+ toCoordinateSpace: listenerView.window.coordinateSpace];
758
+ #else
749
759
CGPoint screenLocation = [listenerView convertPoint: clientLocation
750
760
toCoordinateSpace: listenerView.window.screen.coordinateSpace];
751
-
761
+ # endif
752
762
UIView *targetView = [listenerView hitTest: clientLocation withEvent: nil ];
753
763
targetView = FindClosestFabricManagedTouchableView (targetView);
754
764
@@ -770,7 +780,6 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer
770
780
eventEmitter->onPointerMove (event);
771
781
}
772
782
}
773
- #endif
774
783
}
775
784
776
785
@end
0 commit comments