Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hitTest/pointInside support to table node #1987

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import <AsyncDisplayKit/ASTableLayoutController.h>
#import <AsyncDisplayKit/ASBatchContext.h>
#import <AsyncDisplayKit/ASTableView+Undeprecated.h>

#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>

static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";

Expand Down Expand Up @@ -287,6 +287,11 @@ @interface ASTableView () <ASRangeControllerDataSource, ASRangeControllerDelegat

@implementation ASTableView
{
struct _ASDisplayViewInternalFlags {
unsigned inHitTest:1;
unsigned inPointInside:1;
} _internalFlags;

__weak id<ASTableDelegate> _asyncDelegate;
__weak id<ASTableDataSource> _asyncDataSource;
}
Expand Down Expand Up @@ -2032,6 +2037,30 @@ - (void)didMoveToSuperview
}
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (!_internalFlags.inHitTest) {
_internalFlags.inHitTest = YES;
UIView *hitView = [_tableNode hitTest:point withEvent:event];
_internalFlags.inHitTest = NO;
return hitView;
} else {
return [super hitTest:point withEvent:event];
}
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if (!_internalFlags.inPointInside) {
_internalFlags.inPointInside = YES;
BOOL result = [_tableNode pointInside:point withEvent:event];
_internalFlags.inPointInside = NO;
return result;
} else {
return [super pointInside:point withEvent:event];
}
}

#pragma mark - Accessibility overrides

- (NSArray *)accessibilityElements
Expand Down