Lemur TextField keys are not exclusively for the input

I don’t know if it’s expected behavior or if I need to set a flag somewhere. I have a TextField and the focus is on the field. As I press “c” I see the character “c” is being entered in the field but also I see the camera debug output of JME SimpleApplication. I would have expected that the text field swallowed the key event because it has focus. I wouldn’t want to move the game map while the user is entering the avatar’s name and is hitting the “a”, “w”, “s” or “d” keys. Did I missed a flag in Lemur or is this the normal behavior?

You need to use

inputManager.deleteMapping( SimpleApplication.INPUT_MAPPING_CAMERA_POS ); 
1 Like

JME provides no way to swallow keys other than to mark the events as consumed… but that presumes that Lemur was the first to register the key listener. Since the JME debug keys are added before anything else gets a chance (usually) then they will always get a first crack at the event, no matter what.

Normal keys that you register for yourself after initializing Lemur will work as you expect.

Actually, to be honest, it may have to do with where you are initializing Lemur now that I think about it. My memory says the debug keys are initialized in an app state that is included by default… which would be run after simpleInit(). If you initialize Lemur in simpleInit() then typing a ‘c’ in a TextField should not trigger the camera debug message.

If you are initializing Lemur in an app state then you will have to make sure your app state runs before the debug keys app state… so you should be providing the app states you want on the super() constructor for your application class.

Like this:

And I just tried that demo and if I run the text entry demo I can type as many ‘c’ keys as I want and the camera debug stuff never shows up… until I’m not in a text field anymore.

1 Like