@@ -50,9 +50,6 @@ @interface ASControlNode ()
5050@property (nonatomic , readwrite , assign , getter =isTracking) BOOL tracking;
5151@property (nonatomic , readwrite , assign , getter =isTouchInside) BOOL touchInside;
5252
53- // ! @abstract Indicates whether the receiver is interested in receiving touches.
54- - (BOOL )_isInterestedInTouches ;
55-
5653/* *
5754 @abstract Returns a key to be used in _controlEventDispatchTable that identifies the control event.
5855 @param controlEvent A control event.
@@ -91,7 +88,7 @@ - (id)init
9188- (void )touchesBegan : (NSSet *)touches withEvent : (UIEvent *)event
9289{
9390 // If we're not interested in touches, we have nothing to do.
94- if (![ self _isInterestedInTouches ] )
91+ if (!self. enabled )
9592 return ;
9693
9794 ASControlNodeEvent controlEventMask = 0 ;
@@ -127,7 +124,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
127124- (void )touchesMoved : (NSSet *)touches withEvent : (UIEvent *)event
128125{
129126 // If we're not interested in touches, we have nothing to do.
130- if (![ self _isInterestedInTouches ] )
127+ if (!self. enabled )
131128 return ;
132129
133130 NSParameterAssert ([touches count ] == 1 );
@@ -153,7 +150,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
153150- (void )touchesCancelled : (NSSet *)touches withEvent : (UIEvent *)event
154151{
155152 // If we're not interested in touches, we have nothing to do.
156- if (![ self _isInterestedInTouches ] )
153+ if (!self. enabled )
157154 return ;
158155
159156 // We're no longer tracking and there is no touch to be inside.
@@ -172,7 +169,7 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
172169- (void )touchesEnded : (NSSet *)touches withEvent : (UIEvent *)event
173170{
174171 // If we're not interested in touches, we have nothing to do.
175- if (![ self _isInterestedInTouches ] )
172+ if (!self. enabled )
176173 return ;
177174
178175 NSParameterAssert ([touches count ] == 1 );
@@ -197,7 +194,12 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
197194
198195- (BOOL )gestureRecognizerShouldBegin : (UIGestureRecognizer *)gestureRecognizer
199196{
200- // similar to UIControl, gestures always win
197+ // 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.
198+ if (self.enabled && [gestureRecognizer isKindOfClass: [UITapGestureRecognizer class ]] && gestureRecognizer.view != self.view ) {
199+ return NO ;
200+ }
201+
202+ // Otherwise, go ahead. :]
201203 return YES ;
202204}
203205
@@ -362,12 +364,6 @@ - (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent:
362364
363365#pragma mark - Convenience
364366
365- - (BOOL )_isInterestedInTouches
366- {
367- // We're only interested in touches if we're enabled
368- return self.enabled ;
369- }
370-
371367id <NSCopying > _ASControlNodeEventKeyForControlEvent (ASControlNodeEvent controlEvent)
372368{
373369 return [NSNumber numberWithInteger: controlEvent];
0 commit comments