From 1f95987d1acf5f9b5e7c5cb94ff4ad179967d4d8 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Thu, 7 Jan 2021 15:06:53 -0800 Subject: [PATCH] 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. --- .../client/game/chatbox/ChatboxTextInput.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java index a11aad1e1c..89cc771cc4 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java +++ b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java @@ -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();