Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,31 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler
- (void)handleGesture:(UIGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateBegan) {
#if TARGET_OS_OSX
// On iOS, this recognizer completing is enough to deny the handler's recognizer —
// UIKit fails a recognizer whose required-to-fail dependency recognizes. AppKit
// does not do this reliably: completing the blocker can flush the dependent
// recognizer's buffered recognition instead of discarding it.
_handler.recognizer.state = UIGestureRecognizerStateFailed;
#endif
self.state = UIGestureRecognizerStateEnded;
[self reset];
}
}

#if TARGET_OS_OSX
- (void)mouseUp:(NSEvent *)event
- (void)mouseDown:(NSEvent *)event
{
[super mouseUp:event];
[super mouseDown:event];

_activePointers -= 1;
_activePointers += 1;
}

- (void)mouseDown:(NSEvent *)event
- (void)mouseUp:(NSEvent *)event
{
[super mouseDown:event];
[super mouseUp:event];

_activePointers += 1;
_activePointers -= 1;

if (_activePointers == 0) {
self.state = UIGestureRecognizerStateBegan;
Expand Down Expand Up @@ -80,6 +87,7 @@ - (void)touchesCancelled:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)ev
- (void)reset
{
self.enabled = YES;
_activePointers = 0;
[super reset];
}

Expand All @@ -106,4 +114,15 @@ - (BOOL)shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGe
return NO;
}

#if TARGET_OS_OSX
// On iOS the method above is a UIGestureRecognizer subclass override, called by the system
// to establish the failure requirement. NSGestureRecognizer has no such subclass hook —
// AppKit only consults the delegate, so forward the delegate callback to the shared logic.
- (BOOL)gestureRecognizer:(NSGestureRecognizer *)gestureRecognizer
shouldBeRequiredToFailByGestureRecognizer:(NSGestureRecognizer *)otherGestureRecognizer
{
return [self shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer];
}
#endif

@end
Loading