fractional clicking support

This commit is contained in:
daboe01
2015-02-24 20:39:42 +01:00
parent 7b9eb4c87c
commit fa6a5f75af
+12
View File
@@ -775,6 +775,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
if (_startTrackingLocation === CPNotFound)
_startTrackingLocation = [_layoutManager numberOfCharacters];
if (fraction[0] > 0.5)
_startTrackingLocation++;
[self setSelectionGranularity:granularities[[event clickCount]]];
var setRange = CPMakeRange(_startTrackingLocation, 0);
@@ -821,6 +824,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
if (index === CPNotFound)
index = _scrollingDownward ? CPMaxRange(oldRange) : oldRange.location;
if (fraction[0] > 0.5)
index++;
if (index > oldRange.location)
{
[self _clearRange:_MakeRangeFromAbs(oldRange.location,index)];
@@ -884,6 +890,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
var dindex= [_layoutManager glyphIndexForPoint:point inTextContainer:_textContainer fractionOfDistanceThroughGlyph:fraction],
oldStickyLoc = _stickyXLocation;
if (fraction[0] > 0.5)
dindex++;
[self _establishSelection:CPMakeRange(dindex, 0) byExtending:NO];
_stickyXLocation = oldStickyLoc;
[self scrollRangeToVisible:CPMakeRange(dindex, 0)]
@@ -925,6 +934,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
var dindex = [_layoutManager glyphIndexForPoint:point inTextContainer:_textContainer fractionOfDistanceThroughGlyph:fraction],
oldStickyLoc = _stickyXLocation;
if (fraction[0] > 0.5)
dindex++;
[self _establishSelection:CPMakeRange(dindex,0) byExtending:NO];
_stickyXLocation = oldStickyLoc;
[self scrollRangeToVisible:CPMakeRange(dindex, 0)];