How can I temporarily lock all input? #708
nightm4re94
started this conversation in
Old Forum
Replies: 1 comment
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). Game.window().getHostControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
// whenever the game window lost focus
Game.screens().current().setEnabled(false);
}
@Override
public void focusGained(FocusEvent e) {
// whenever the game window gains focus
Game.screens().current().setEnabled(true);
}
}); I think the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022).
Posted: 2020-02-12 12:57:07
User: KvaGram [] (age: 1068 days 🔥; posts: 52)
I use a Swing-based command line for testing new game features.
Unfortunately, typing in this command line also provides input to my unfinished Liti-engine based UI.
This is annoying.
I'm looking for some general fix for this. Is there a configuration setting that disables keyboard input when the game window is not in focus?
Or maybe a toggle that would let me turn on and off input at will?
I looked, but couldn't find any.
I can easily make a check if the command-line is in focus, but I'd rather not copy-paste that check in every key listener method.
I got the command line's controller class hooked up to the game loop, so if a toggle exist, I could insert it there.
Beta Was this translation helpful? Give feedback.
All reactions