From 90a97e62723a6aada8988d780d305bbf5b9e1c70 Mon Sep 17 00:00:00 2001 From: GordoRank Date: Tue, 14 Jan 2014 15:48:59 +0000 Subject: [PATCH] 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 --- src/shapes/itext.class.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shapes/itext.class.js b/src/shapes/itext.class.js index 5492db10..cd244517 100644 --- a/src/shapes/itext.class.js +++ b/src/shapes/itext.class.js @@ -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);