Skip to content
Permalink
Browse files

Fix textarea bug: clicking right of the end of a line caused the curs…

…or to be in one of the next lines (#3474)
  • Loading branch information
HybridDog authored and nerzhul committed May 19, 2017
1 parent 75c393c commit a4a377ecad6f1732cc54e7ac329fdef9949f9bf7
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/intlGUIEditBox.cpp
@@ -1120,14 +1120,16 @@ s32 intlGUIEditBox::getCursorPos(s32 x, s32 y)

if (x < CurrentTextRect.UpperLeftCorner.X)
x = CurrentTextRect.UpperLeftCorner.X;
else if (x > CurrentTextRect.LowerRightCorner.X)
x = CurrentTextRect.LowerRightCorner.X;

s32 idx = font->getCharacterFromPos(Text.c_str(), x - CurrentTextRect.UpperLeftCorner.X);

// click was on or left of the line
if (idx != -1)
return idx + startPos;

// click was off the right edge of the line, go to end.
// click was off the right edge of the last line, go to end.
return txtLine->size() + startPos;
}

1 comment on commit a4a377e

@Fixer-007

This comment has been minimized.

Copy link
Contributor

@Fixer-007 Fixer-007 commented on a4a377e May 19, 2017

Detected regression... will post an issue.

Please sign in to comment.