keyremapping: fix race with sending messages and clearing chat input
It is not necessary to clear the chat input when locking chat when a message would be sent.
Currently this races with the key handlers where it can sometimes clear the chatbox input
prior to enter being processed, resulting in dropped messages
This was introduced in b5acb61771
This commit is contained in:
@@ -182,10 +182,16 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener
|
||||
switch (e.getKeyCode())
|
||||
{
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
// When existing typing mode, block the escape key
|
||||
// When exiting typing mode, block the escape key
|
||||
// so that it doesn't trigger the in-game hotkeys
|
||||
e.consume();
|
||||
// FALLTHROUGH
|
||||
plugin.setTyping(false);
|
||||
clientThread.invoke(() ->
|
||||
{
|
||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
||||
plugin.lockChat();
|
||||
});
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
plugin.setTyping(false);
|
||||
clientThread.invoke(plugin::lockChat);
|
||||
|
||||
@@ -88,6 +88,8 @@ public class KeyRemappingPlugin extends Plugin
|
||||
if (client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
lockChat();
|
||||
// Clear any typed text
|
||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -178,8 +180,6 @@ public class KeyRemappingPlugin extends Plugin
|
||||
if (chatboxInput != null)
|
||||
{
|
||||
chatboxInput.setText(getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT);
|
||||
// Typed text can be non-empty on plugin start, so clear it now
|
||||
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user