fix caret position

This commit is contained in:
daboe01 committed 2015-06-29 20:19:47 +02:00
1 parent 26a2e9ef53
commit 587d8fbfa9
2 files changed
+12 -2

No files matched your search

+6 -2
View File
@@ -695,8 +695,12 @@ _oncontextmenuhandler = function () { return false; };
- (CGPoint)_realCharacterLocationAtLocation:(unsigned)location
{
var lineFragment = _objectWithLocationInRange(_lineFragments, location),
index = location - lineFragment._range.location;
var lineFragment = _objectWithLocationInRange(_lineFragments, location);
if (!lineFragment)
return CGPointMake(0, 0);
var index = location - lineFragment._range.location;
return CGPointMake(lineFragment._glyphsFrames[index].origin.x,
lineFragment._glyphsFrames[index].origin.y + lineFragment._glyphsOffsets[index]);
+6
View File
@@ -1776,6 +1776,12 @@ var kDelegateRespondsTo_textShouldBeginEditing
caretRect = [_layoutManager boundingRectForGlyphRange:CPMakeRange(_selectionRange.location, 1) inTextContainer:_textContainer];
}
var caretOrigin = [_layoutManager _realCharacterLocationAtLocation:_selectionRange.location],
oldYPosition = CGRectGetMaxY(caretRect);
caretRect.origin = caretOrigin;
caretRect.size.height = oldYPosition - caretRect.origin.y;
caretRect.origin.x += _textContainerOrigin.x;
caretRect.origin.y += _textContainerOrigin.y;
caretRect.size.width = 1;