Skip to content

Commit

Permalink
Fix textarea bug: clicking right of the end of a line caused the curs…
Browse files Browse the repository at this point in the history
…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 a4a377e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/intlGUIEditBox.cpp
Expand Up @@ -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;
}

Expand Down

1 comment on commit a4a377e

@Fixer-007
Copy link
Contributor

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detected regression... will post an issue.

Please sign in to comment.