diff options
author | xander <xander@isxander.dev> | 2022-09-03 10:59:58 +0100 |
---|---|---|
committer | xander <xander@isxander.dev> | 2022-09-03 10:59:58 +0100 |
commit | 8a29f957e99c957efd11d6c279e5f97639f05d9e (patch) | |
tree | f94a9d48d8d409b526d494ad6cd593f73ba81dea /src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java | |
parent | 0ec15d2b53ccec94b17d9571bc7d4c437df84eae (diff) | |
download | YetAnotherConfigLib-8a29f957e99c957efd11d6c279e5f97639f05d9e.tar.gz YetAnotherConfigLib-8a29f957e99c957efd11d6c279e5f97639f05d9e.tar.bz2 YetAnotherConfigLib-8a29f957e99c957efd11d6c279e5f97639f05d9e.zip |
prevent keyboard controls if not hovered or focused
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java b/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java index d198c96..e0d0230 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java @@ -88,13 +88,16 @@ public class ActionController implements Controller<Consumer<YACLScreen>> { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (keyCode != GLFW.GLFW_KEY_ENTER && keyCode != GLFW.GLFW_KEY_SPACE && keyCode != GLFW.GLFW_KEY_KP_ENTER) { + if (!focused && !hovered) { return false; } - executeAction(); + if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_SPACE || keyCode == GLFW.GLFW_KEY_KP_ENTER) { + executeAction(); + return true; + } - return true; + return false; } @Override |