Permalink
Browse files

Merge pull request #358 from migrant/master

NIAttributedLabel
  • Loading branch information...
2 parents 92e481e + 3cbbe8a commit 16e0ecc48d80c968e1cc7189c995c9d1e7165b70 @jverkoey committed Mar 26, 2013
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/attributedlabel/src/NIAttributedLabel.m
@@ -788,9 +788,20 @@ - (NSTextCheckingResult *)linkAtPoint:(CGPoint)point {
CGPoint relativePoint = CGPointMake(point.x-CGRectGetMinX(rect),
point.y-CGRectGetMinY(rect));
CFIndex idx = CTLineGetStringIndexForPosition(line, relativePoint);
- foundLink = [self linkAtIndex:idx];
+
+ NSUInteger offset = 0;
+ for (NIAttributedLabelImage *labelImage in self.images) {
+ if (labelImage.index < idx) {
+ offset++;
+ }
+
+ }
+
+ foundLink = [self linkAtIndex:idx - offset];;
if (foundLink) {
- return foundLink;
+ NSTextCheckingResult *result = [NSTextCheckingResult linkCheckingResultWithRange:NSMakeRange(foundLink.range.location + offset, foundLink.range.length) URL:foundLink.URL];
+
+ return result;
}
}
}

0 comments on commit 16e0ecc

Please sign in to comment.