Fix click cursor placement on center/right text

This clamps the click cursor placement so that clicking to the left of a short first line of centered/right aligned text positions the cursor to the left of the first character in the line....

Previously in that instance it would move to the left boundary instead
This commit is contained in:
GordoRank 2014-01-14 15:48:59 +00:00
parent 77f304bed0
commit 90a97e6272

View file

@ -481,13 +481,16 @@
var cursorLocation = this.get2DCursorLocation(),
lineIndex = cursorLocation.lineIndex,
charIndex = cursorLocation.charIndex,
charHeight = this.getCurrentCharFontSize(lineIndex, charIndex);
charHeight = this.getCurrentCharFontSize(lineIndex, charIndex),
leftOffset = (lineIndex == 0 && charIndex == 0)
? this._getCachedLineOffset(lineIndex, this.text.split(this._reNewline))
: boundaries.leftOffset;
ctx.fillStyle = this.getCurrentCharColor(lineIndex, charIndex);
ctx.globalAlpha = this.__isMousedown ? 1 : this._currentCursorOpacity;
ctx.fillRect(
boundaries.left + boundaries.leftOffset,
boundaries.left + leftOffset,
boundaries.top + boundaries.topOffset,
this.cursorWidth / this.scaleX,
charHeight);