ChatboxTextInput: Improve open selection left/right handling

Previously, when pressing left or right without Shift pressed, the
cursor would end up one character left or right of the start of the
selection, which is not expected behavior compared to how most programs
handle this case. This commit changes this behavior to place the cursor
at the start or end of the selection when pressing left or right,
respectively, when a selection is active.
This commit is contained in:
Jordan Atwood
2021-01-07 15:06:53 -08:00
parent ae18d2a865
commit 1f95987d1a

View File

@@ -753,11 +753,25 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
return;
case KeyEvent.VK_LEFT:
ev.consume();
newPos--;
if (cursorStart != cursorEnd)
{
newPos = cursorStart;
}
else
{
newPos--;
}
break;
case KeyEvent.VK_RIGHT:
ev.consume();
newPos++;
if (cursorStart != cursorEnd)
{
newPos = cursorEnd;
}
else
{
newPos++;
}
break;
case KeyEvent.VK_UP:
ev.consume();