key remapping: don't remap fkeys when options dialog is open

This commit is contained in:
Adam
2019-06-07 17:34:32 -04:00
parent 59886b084a
commit bb25aee4cc
2 changed files with 24 additions and 1 deletions

View File

@@ -107,7 +107,10 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener
}
}
if (config.fkeyRemap())
// In addition to the above checks, the F-key remapping shouldn't
// activate when dialogs are open which listen for number keys
// to select options
if (config.fkeyRemap() && !plugin.isDialogOpen())
{
if (ONE.matches(e))
{

View File

@@ -131,6 +131,26 @@ public class KeyRemappingPlugin extends Plugin
return true;
}
/**
* Check if a dialog is open that will grab numerical input, to prevent F-key remapping
* from triggering.
*
* @return
*/
boolean isDialogOpen()
{
// Most chat dialogs with numerical input are added without the chatbox or its key listener being removed,
// so chatboxFocused() is true. The chatbox onkey script uses the following logic to ignore key presses,
// so we will use it too to not remap F-keys.
return isHidden(WidgetInfo.CHATBOX_MESSAGES) || isHidden(WidgetInfo.CHATBOX_TRANSPARENT_LINES);
}
private boolean isHidden(WidgetInfo widgetInfo)
{
Widget w = client.getWidget(widgetInfo);
return w == null || w.isSelfHidden();
}
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
{