Lemur's requestFocus is consuming some "onaction" events

Well, I’m experimenting a problem with Lemur’s GuiGlobals.requestFocus. I use it to set the focus to a text field:

GuiGlobals.getInstance().requestFocus(textField);

The textfield is in a custom element that I added to the scene with:

guiNode.attachChild(myElement);

All works as I desire until I remove the element and I want my old input functionality back. I restore the input listeners and I remove the element from the node but the “onAction” is no long receiving pressed events (when I release a key, so the pressed value is false on the “onAction”, it works well but not for pressed ones, when true).

So, in resume:

  1. I remove my player input listener.
  2. I show the lemur’s element on the screen (I attach the element node).
  3. I set the focus on added the lemur’s element.
  4. I remove the lemur’s element from the screen.
  5. I add my player input listener.
    result: all key events are fine but the “press” ones (just the analogs and the key releases actions).

I found that with GuiGlobals.getInstance().requestFocus(rootNode); it works fine again but I’m not sure if this is the right procedure and if it is not leading to further problems.
All help is appreciated.

1 Like

Ah, thanks for the report. It sounds like maybe the focus isn’t being released when the component is detached.

Your work-around essentially confirms this. (Though note you can also requestFocus(null) to clear the current focus.)

If you are feeling extra generous, maybe you can enter a bug for it.

Else I will try to remember to fix it soon. I’m overdue for a release anyway…

-O- I didn’t think on it. I just submitted it to github (I can’t label it with “bug”).

I labeled it. Thanks for entering it.