From a92dd3189b02cfa425867ee6329dff7fd02ff2ef Mon Sep 17 00:00:00 2001 From: Michael Kuntscher Date: Wed, 1 Apr 2015 16:38:29 -0700 Subject: [PATCH] Adds property for long press touch cancellation --- AsyncDisplayKit/ASTextNode.h | 6 ++++++ AsyncDisplayKit/ASTextNode.mm | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASTextNode.h b/AsyncDisplayKit/ASTextNode.h index b0b80f9d..11fe337d 100644 --- a/AsyncDisplayKit/ASTextNode.h +++ b/AsyncDisplayKit/ASTextNode.h @@ -187,6 +187,12 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) { */ @property (nonatomic, weak) id delegate; +/** + @abstract If YES and a long press is recognized, touches are cancelled. Default is NO + */ +@property (nonatomic, assign) BOOL longPressCancelsTouches; + + @end /** diff --git a/AsyncDisplayKit/ASTextNode.mm b/AsyncDisplayKit/ASTextNode.mm index d6d1a46a..e631f9d2 100644 --- a/AsyncDisplayKit/ASTextNode.mm +++ b/AsyncDisplayKit/ASTextNode.mm @@ -240,7 +240,7 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f) // If we are view-backed, support gesture interaction. if (!self.isLayerBacked) { _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_handleLongPress:)]; - _longPressGestureRecognizer.cancelsTouchesInView = NO; + _longPressGestureRecognizer.cancelsTouchesInView = self.longPressCancelsTouches; _longPressGestureRecognizer.delegate = self; [self.view addGestureRecognizer:_longPressGestureRecognizer]; }