KeybindingManager JTextfield conflict

Is there a way to disable the KeyBindingManager while using swing components like JTextfield i JMEDesktop?



The problem is that I have functions tied to the number keys in the keybinding manager. When I input a numeral value in a textfield these functions get called.

You could always detect focus of the mouse, then flip the input to the canvas with focus.


You cannot switch off the keybinding manager but you can switch of the InputHandler using it (setEnabled). Just be sure to separate the InputHandler for the desktop and the other stuff. The commands you don't handler with InputHandler but with isValidCommand simply should not get executed while you don't want them to. Something like this:

in init:

input = new InputHandler();
myMovementHandler = new FirstPersonHandler( ... );
myDesktopHandler = new InputHandler();
myMovementHandler.addAction( myAction, "bla", ... , myKeys ); // <- register actions for keybinding manager
...
desktop = new JMEDesktop( ..., myDesktopHandler );


in update:

if ( desktopDoesNotWantInput )
   myMovementHandler.setEnabled( false );
else {
   myMovementHandler.setEnabled( true );
   if ( KeyBindingManager.get...isValidCommand(...) ) { executeMyCommands(); } // <- perform non-InputHandler commands only if suited
}

Thanks, thats what I needed.