diff --git a/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm b/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm index a69a0123e2..4f28da6e1b 100644 --- a/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm +++ b/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm @@ -1197,7 +1197,6 @@ - (void)mouseDown:(NSEvent *)event return; } - _isTouchInsideBounds = YES; [self handleAnimatePressIn]; [super mouseDown:event]; @@ -1208,7 +1207,7 @@ - (void)mouseUp:(NSEvent *)event if (!_userEnabled) { return; } - + NSPoint locationInView = [self convertPoint:[event locationInWindow] fromView:nil]; _isHovered = NSPointInRect(locationInView, self.bounds); [self recordHoverSampleForMouseEvent:event]; @@ -1224,7 +1223,7 @@ - (void)mouseDragged:(NSEvent *)event if (!_userEnabled) { return; } - + NSPoint locationInWindow = [event locationInWindow]; NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil]; BOOL currentlyInside = NSPointInRect(locationInView, self.bounds); @@ -1260,7 +1259,7 @@ - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event if (!_userEnabled) { return NO; } - + _isTouchInsideBounds = YES; // A pencil's hover-out arrives just before touch-down but only schedules the // clear, so `_isHovered` still reflects the open hover. Under Reduce Motion @@ -1426,7 +1425,8 @@ - (BOOL)shouldHandleTouch:(RNGHUIView *)view atPoint:(CGPoint)point { if ([view isKindOfClass:[RNGestureHandlerButton class]]) { RNGestureHandlerButton *button = (RNGestureHandlerButton *)view; - return button.userEnabled; + return button.userEnabled && button.pointerEvents != RNGestureHandlerPointerEventsBoxNone && + button.pointerEvents != RNGestureHandlerPointerEventsNone; } // Certain subviews such as RCTViewComponentView have been observed to have disabled @@ -1473,7 +1473,9 @@ - (RNGHUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event if (!subview.isHidden && subview.alpha > 0) { CGPoint convertedPoint = [subview convertPoint:point fromView:self]; UIView *hitView = [subview hitTest:convertedPoint withEvent:event]; - if (hitView != nil && [self shouldHandleTouch:hitView atPoint:point]) { + if (hitView != nil && + ([hitView isKindOfClass:[RNGestureHandlerButton class]] || + [self shouldHandleTouch:hitView atPoint:point])) { return hitView; } }