mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-25 15:01:38 +00:00
Merge pull request #439 from eanagel/passthrough-nonlink-touches
Add option to pass through touches to non-link text in ASTextNode
This commit is contained in:
commit
2bc0da021f
@ -194,6 +194,11 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL longPressCancelsTouches;
|
||||
|
||||
/**
|
||||
@abstract if YES will not intercept touches for non-link areas of the text. Default is NO.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL passthroughNonlinkTouches;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
@ -769,6 +769,33 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f)
|
||||
|
||||
#pragma mark - Touch Handling
|
||||
|
||||
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
if (!_passthroughNonlinkTouches) {
|
||||
return [super pointInside:point withEvent:event];
|
||||
}
|
||||
|
||||
NSRange range = NSMakeRange(0, 0);
|
||||
NSString *linkAttributeName = nil;
|
||||
BOOL inAdditionalTruncationMessage = NO;
|
||||
|
||||
id linkAttributeValue = [self _linkAttributeValueAtPoint:point
|
||||
attributeName:&linkAttributeName
|
||||
range:&range
|
||||
inAdditionalTruncationMessage:&inAdditionalTruncationMessage];
|
||||
|
||||
NSUInteger lastCharIndex = NSIntegerMax;
|
||||
BOOL linkCrossesVisibleRange = (lastCharIndex > range.location) && (lastCharIndex < NSMaxRange(range) - 1);
|
||||
|
||||
if (inAdditionalTruncationMessage) {
|
||||
return YES;
|
||||
} else if (range.length && !linkCrossesVisibleRange && linkAttributeValue != nil && linkAttributeName != nil) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
Loading…
x
Reference in New Issue
Block a user