From d8f5d135b09f29dfca298c064e53a95c0ab7fd56 Mon Sep 17 00:00:00 2001 From: Ryan Nystrom Date: Wed, 18 Feb 2015 17:09:49 -0800 Subject: [PATCH] Revert ASControlNode to previous touch/gesture handling --- AsyncDisplayKit/ASControlNode.m | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/AsyncDisplayKit/ASControlNode.m b/AsyncDisplayKit/ASControlNode.m index 953b77e3f3..34063b30d0 100644 --- a/AsyncDisplayKit/ASControlNode.m +++ b/AsyncDisplayKit/ASControlNode.m @@ -50,9 +50,6 @@ @property (nonatomic, readwrite, assign, getter=isTracking) BOOL tracking; @property (nonatomic, readwrite, assign, getter=isTouchInside) BOOL touchInside; -//! @abstract Indicates whether the receiver is interested in receiving touches. -- (BOOL)_isInterestedInTouches; - /** @abstract Returns a key to be used in _controlEventDispatchTable that identifies the control event. @param controlEvent A control event. @@ -91,7 +88,7 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // If we're not interested in touches, we have nothing to do. - if (![self _isInterestedInTouches]) + if (!self.enabled) return; ASControlNodeEvent controlEventMask = 0; @@ -127,7 +124,7 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // If we're not interested in touches, we have nothing to do. - if (![self _isInterestedInTouches]) + if (!self.enabled) return; NSParameterAssert([touches count] == 1); @@ -153,7 +150,7 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { // If we're not interested in touches, we have nothing to do. - if (![self _isInterestedInTouches]) + if (!self.enabled) return; // We're no longer tracking and there is no touch to be inside. @@ -172,7 +169,7 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { // If we're not interested in touches, we have nothing to do. - if (![self _isInterestedInTouches]) + if (!self.enabled) return; NSParameterAssert([touches count] == 1); @@ -197,7 +194,12 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { - // similar to UIControl, gestures always win + // If we're interested in touches, this is a tap (the only gesture we care about) and passed -hitTest for us, then no, you may not begin. Sir. + if (self.enabled && [gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] && gestureRecognizer.view != self.view) { + return NO; + } + + // Otherwise, go ahead. :] return YES; } @@ -362,12 +364,6 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v #pragma mark - Convenience -- (BOOL)_isInterestedInTouches -{ - // We're only interested in touches if we're enabled - return self.enabled; -} - id _ASControlNodeEventKeyForControlEvent(ASControlNodeEvent controlEvent) { return [NSNumber numberWithInteger:controlEvent];