mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 09:52:03 +00:00
fix caret position
This commit is contained in:
1 parent
26a2e9ef53
commit
587d8fbfa9
2 files changed
+12
-2
No files matched your search
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user