rl-client: Prevent chat inputs from taking keys from the worldmap search

KeyRemapping has this check too, and [proc,keypress_permit] has similar,
though not identical one.
This commit is contained in:
Max Weber
2020-06-26 22:52:19 -06:00
committed by Adam
parent 4308d433a2
commit eb251a7e85
5 changed files with 38 additions and 0 deletions

View File

@@ -184,6 +184,11 @@ public class ChatboxItemSearch extends ChatboxTextInput
@Override
public void keyPressed(KeyEvent ev)
{
if (!chatboxPanelManager.shouldTakeInput())
{
return;
}
switch (ev.getKeyCode())
{
case KeyEvent.VK_ENTER:

View File

@@ -199,4 +199,12 @@ public class ChatboxPanelManager
{
return client.getWidget(WidgetInfo.CHATBOX_CONTAINER);
}
public boolean shouldTakeInput()
{
// the search box on the world map can be focused, and chat input goes there, even
// though the chatbox still has its key listener.
Widget worldMapSearch = client.getWidget(WidgetInfo.WORLD_MAP_SEARCH);
return worldMapSearch == null || client.getVar(VarClientInt.WORLD_MAP_SEARCH_FOCUSED) != 1;
}
}

View File

@@ -609,6 +609,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
@Override
public void keyTyped(KeyEvent e)
{
if (!chatboxPanelManager.shouldTakeInput())
{
return;
}
char c = e.getKeyChar();
if (charValidator.test(c))
{
@@ -628,6 +633,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
@Override
public void keyPressed(KeyEvent ev)
{
if (!chatboxPanelManager.shouldTakeInput())
{
return;
}
int code = ev.getKeyCode();
if (ev.isControlDown())
{

View File

@@ -178,6 +178,11 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
@Override
public void keyTyped(KeyEvent e)
{
if (!chatboxPanelManager.shouldTakeInput())
{
return;
}
char c = e.getKeyChar();
if (c == '\033')
@@ -198,6 +203,11 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
@Override
public void keyPressed(KeyEvent e)
{
if (!chatboxPanelManager.shouldTakeInput())
{
return;
}
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
{
e.consume();

View File

@@ -256,6 +256,11 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput
@Override
public void keyPressed(KeyEvent ev)
{
if (!chatboxPanelManager.shouldTakeInput())
{
return;
}
switch (ev.getKeyCode())
{
case KeyEvent.VK_UP: