diff --git a/forge-gui-mobile/src/forge/adventure/scene/UIScene.java b/forge-gui-mobile/src/forge/adventure/scene/UIScene.java index f8d9236188c..8754117b04d 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/UIScene.java +++ b/forge-gui-mobile/src/forge/adventure/scene/UIScene.java @@ -380,23 +380,18 @@ public class UIScene extends Scene { } } if(!textboxOpen){ - if (stage.getKeyboardFocus() instanceof TextField) { - if (Input.Keys.S != keycode && KeyBinding.Down.isPressed(keycode)) - selectNextDown(); - if (Input.Keys.W != keycode && KeyBinding.Up.isPressed(keycode)) - selectNextUp(); - } else { - if (KeyBinding.Down.isPressed(keycode)) - selectNextDown(); - if (KeyBinding.Up.isPressed(keycode)) - selectNextUp(); - } - if (!(stage.getKeyboardFocus() instanceof Selector) && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)) { - if (KeyBinding.Right.isPressed(keycode)) - selectNextRight(); - if (KeyBinding.Left.isPressed(keycode)) - selectNextLeft(); - } + if (KeyBinding.Down.isPressed(keycode, !(stage.getKeyboardFocus() instanceof TextField)) + || KeyBinding.Down.isPressed(keycode,Input.Keys.S != keycode)) + selectNextDown(); + if (KeyBinding.Up.isPressed(keycode, !(stage.getKeyboardFocus() instanceof TextField)) + || KeyBinding.Up.isPressed(keycode,Input.Keys.W != keycode)) + selectNextUp(); + if (KeyBinding.Right.isPressed(keycode, !(stage.getKeyboardFocus() instanceof Selector) + && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider))) + selectNextRight(); + if (KeyBinding.Left.isPressed(keycode, !(stage.getKeyboardFocus() instanceof Selector) + && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider))) + selectNextLeft(); } if (!dialogShowing()) { Button pressedButton = ui.buttonPressed(keycode); diff --git a/forge-gui-mobile/src/forge/adventure/util/KeyBinding.java b/forge-gui-mobile/src/forge/adventure/util/KeyBinding.java index b58d7c73745..fce1a334136 100644 --- a/forge-gui-mobile/src/forge/adventure/util/KeyBinding.java +++ b/forge-gui-mobile/src/forge/adventure/util/KeyBinding.java @@ -34,9 +34,15 @@ public enum KeyBinding { } public boolean isPressed(int key) { - for (int i = 0; i < bindings.length; i++) { - if (key == bindings[i]) { - return true; + return isPressed(key, null); + } + + public boolean isPressed(int key, Boolean requiredCondition) { + if (requiredCondition == null || requiredCondition) { + for (int i = 0; i < bindings.length; i++) { + if (key == bindings[i]) { + return true; + } } } return false;