Skip to content

Commit

Permalink
Remove text from recognizer
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bert committed Dec 6, 2024
1 parent dbce3f8 commit 65ea0f9
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions apple/Handlers/RNNativeViewHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
#import <React/UIView+React.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTParagraphComponentView.h>
#import <React/RCTScrollViewComponentView.h>
#else
#import <React/RCTScrollView.h>
#import <React/RCTTextView.h>
#endif // RCT_NEW_ARCH_ENABLED

#pragma mark RNDummyGestureRecognizer
Expand All @@ -37,24 +35,11 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler
return self;
}

- (BOOL)isHandlerAttachedToTextView
{
#if RCT_NEW_ARCH_ENABLED
return [self.view.superview isKindOfClass:[RCTParagraphComponentView class]];
#else
return [self.view isKindOfClass:[RCTTextView class]];
#endif
}

#if !TARGET_OS_OSX
- (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler setCurrentPointerType:event];
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];

if ([self isHandlerAttachedToTextView]) {
self.state = UIGestureRecognizerStatePossible;
}
}

- (void)touchesMoved:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
Expand All @@ -66,8 +51,7 @@ - (void)touchesMoved:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler.pointerTracker touchesEnded:touches withEvent:event];

self.state = [self isHandlerAttachedToTextView] ? UIGestureRecognizerStateEnded : UIGestureRecognizerStateFailed;
self.state = UIGestureRecognizerStateFailed;

// For now, we are handling only the scroll view case.
// If more views need special treatment, then we can switch to a delegate pattern
Expand All @@ -88,9 +72,9 @@ - (void)mouseDown:(NSEvent *)event
{
[_gestureHandler setCurrentPointerTypeToMouse];

self.state = [self isHandlerAttachedToTextView] ? NSGestureRecognizerStatePossible : NSGestureRecognizerStateBegan;

[_gestureHandler.pointerTracker touchesBegan:[NSSet setWithObject:event] withEvent:event];
self.state = NSGestureRecognizerStateBegan
[_gestureHandler.pointerTracker touchesBegan:[NSSet setWithObject:event] withEvent:event];
}

- (void)mouseDragged:(NSEvent *)event
Expand Down

0 comments on commit 65ea0f9

Please sign in to comment.