Fix textarea bug: clicking right of the end of a line caused the cursor to be in...
authoryou <ovvv@web.de>
Fri, 19 May 2017 05:57:21 +0000 (07:57 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Fri, 19 May 2017 05:57:21 +0000 (07:57 +0200)
src/intlGUIEditBox.cpp

index 29f82807653a11340535fc1555b764a7b020c7c4..4cc2d746f628f5f2ec044cbf6ee32f7a59860bc4 100644 (file)
@@ -1120,6 +1120,8 @@ 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);
 
@@ -1127,7 +1129,7 @@ s32 intlGUIEditBox::getCursorPos(s32 x, s32 y)
        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;
 }