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:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user