diff --git a/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm b/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm index b480fa93e3..a69a0123e2 100644 --- a/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm +++ b/packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm @@ -1193,6 +1193,11 @@ - (void)mouseExited:(NSEvent *)event - (void)mouseDown:(NSEvent *)event { + if (!_userEnabled) { + return; + } + + _isTouchInsideBounds = YES; [self handleAnimatePressIn]; [super mouseDown:event]; @@ -1200,6 +1205,10 @@ - (void)mouseDown:(NSEvent *)event - (void)mouseUp:(NSEvent *)event { + if (!_userEnabled) { + return; + } + NSPoint locationInView = [self convertPoint:[event locationInWindow] fromView:nil]; _isHovered = NSPointInRect(locationInView, self.bounds); [self recordHoverSampleForMouseEvent:event]; @@ -1212,6 +1221,10 @@ - (void)mouseUp:(NSEvent *)event - (void)mouseDragged:(NSEvent *)event { + if (!_userEnabled) { + return; + } + NSPoint locationInWindow = [event locationInWindow]; NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil]; BOOL currentlyInside = NSPointInRect(locationInView, self.bounds); @@ -1244,6 +1257,10 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event - (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 @@ -1469,7 +1486,7 @@ - (RNGHUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event } RNGHUIView *inner = [super hitTest:point withEvent:event]; - while (inner && ![self shouldHandleTouch:inner atPoint:point]) { + while (inner && inner != self && ![self shouldHandleTouch:inner atPoint:point]) { inner = inner.superview; } return inner;