Skip to content

Commit

Permalink
Fix #99 and #55
Browse files Browse the repository at this point in the history
  • Loading branch information
AliSoftware committed Nov 18, 2012
1 parent 6dcd3d3 commit 3d46deb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions OHAttributedLabel/Source/OHAttributedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,14 @@ -(NSTextCheckingResult*)linkAtPoint:(CGPoint)point
CGPoint relativePoint = CGPointMake(point.x-CGRectGetMinX(lineRect),
point.y-CGRectGetMinY(lineRect));
CFIndex idx = CTLineGetStringIndexForPosition(line, relativePoint);
if ((relativePoint.x < CTLineGetOffsetForStringIndex(line, idx, NULL)) && (idx>0))
{
// CTLineGetStringIndexForPosition compute the *carret* position, not the character under the CGPoint. So if the index
// returned correspond to the character *after* the tapped point, because we tapped on the right half of the character,
// then substract 1 to the index to get to the real tapped character index.
--idx;
}

link = ([self linkAtCharacterIndex:idx]);
if (link)
{
Expand Down

0 comments on commit 3d46deb

Please sign in to comment.