From 597aa02c8ecf6391ed81c704e7fb90da9fcb0bca Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Wed, 3 Feb 2016 18:53:20 -0800 Subject: [PATCH] Remove target added state and and instead check _controlEventDispatchTable if a target was added --- AsyncDisplayKit/ASControlNode.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/AsyncDisplayKit/ASControlNode.m b/AsyncDisplayKit/ASControlNode.m index 3ccb2ef7bd..4356c66906 100644 --- a/AsyncDisplayKit/ASControlNode.m +++ b/AsyncDisplayKit/ASControlNode.m @@ -23,7 +23,6 @@ { @private // Control Attributes - BOOL _targetAdded; BOOL _enabled; BOOL _highlighted; @@ -88,14 +87,14 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v [super didLoad]; // As we have no targets yet, we start off with user interaction off. When a target is added, it'll get turned back on. - if (!_targetAdded) { + if (![self hasTarget]) { self.userInteractionEnabled = NO; } } - (BOOL)shouldTrackTouches { - return _targetAdded && self.enabled; + return [self hasTarget] && self.enabled; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event @@ -269,7 +268,6 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v [targetActions addObject:NSStringFromSelector(action)]; }); - _targetAdded = YES; self.userInteractionEnabled = YES; } @@ -351,9 +349,16 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v else removeActionFromTarget(target, action); }); + + self.userInteractionEnabled = [self hasTarget]; } #pragma mark - +- (BOOL)hasTarget +{ + return (_controlEventDispatchTable.count > 0); +} + - (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent:(UIEvent *)event { NSParameterAssert(controlEvents != 0);