fixed: target index in selection dragging was sometimes wrong

This commit is contained in:
daboe01
2016-09-28 17:24:39 +02:00
parent 2217b560cb
commit 4befe17cab
+6 -3
View File
@@ -942,11 +942,11 @@ var kDelegateRespondsTo_textShouldBeginEditing
_movingSelection = CPMakeRange(_startTrackingLocation, 0);
var dragPlaceholder = [CPTextField new],
originPoint = [_layoutManager locationForGlyphAtIndex:[self selectedRange].location];
originPoint.y -= [_layoutManager _descentAtLocation:_selectionRange.location];
originPoint.y += [_layoutManager _characterOffsetAtLocation:_selectionRange.location] + _textContainerOrigin.y - 1;
originPoint.x += _textContainerOrigin.x;
originPoint.y += _textContainerOrigin.y;
dragPlaceholder._DOMElement.style.opacity = '0.6';
[dragPlaceholder setStringValue:[[self stringValue] substringWithRange:_selectionRange]];
[dragPlaceholder sizeToFit];
@@ -2025,6 +2025,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
return;
}
if (_movingSelection.location > CPMaxRange(_selectionRange))
_movingSelection.location -= _selectionRange.length;
[self _deleteForRange:_selectionRange];
[self setSelectedRange:_movingSelection];