Home asdisplaynode-gesturerecognizer
Post
Cancel

asdisplaynode-gesturerecognizer

ASDisplayNode.mm

touchesBegan

1
2
3
4
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  // Subclass hook
}

touchesMoved

1
2
3
4
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
  // Subclass hook
}

touchesEnded

1
2
3
4
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
  // Subclass hook
}

touchesCancelled

1
2
3
4
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
  // Subclass hook
}

gestureRecognizerShouldBegin

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
  // This method is only implemented on UIView on iOS 6+.
  ASDisplayNodeAssertMainThread();
  
  // No locking needed as it's main thread only
  UIView *view = _view;
  if (view == nil) {
    return YES;
  }

  // If we reach the base implementation, forward up the view hierarchy.
  UIView *superview = view.superview;
  return [superview gestureRecognizerShouldBegin:gestureRecognizer];
}

hitTest

1
2
3
4
5
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
  ASDisplayNodeAssertMainThread();
  return [_view hitTest:point withEvent:event];
}

setHitTestSlop

1
2
3
4
5
- (void)setHitTestSlop:(UIEdgeInsets)hitTestSlop
{
  MutexLocker l(__instanceLock__);
  _hitTestSlop = hitTestSlop;
}

pointInside

1
2
3
4
5
6
7
8
9
10
11
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
  ASDisplayNodeAssertMainThread();
  UIEdgeInsets slop = self.hitTestSlop;
  if (_view && UIEdgeInsetsEqualToEdgeInsets(slop, UIEdgeInsetsZero)) {
    // Safer to use UIView's -pointInside:withEvent: if we can.
    return [_view pointInside:point withEvent:event];
  } else {
    return CGRectContainsPoint(UIEdgeInsetsInsetRect(self.bounds, slop), point);
  }
}
This post is licensed under CC BY 4.0 by the author.