Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestFocus is consuming some "onAction" events #28

Closed
NemesisMate opened this issue Jan 26, 2016 · 3 comments
Closed

requestFocus is consuming some "onAction" events #28

NemesisMate opened this issue Jan 26, 2016 · 3 comments
Labels
Milestone

Comments

@NemesisMate
Copy link

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.

@pspeed42 pspeed42 added the bug label Jan 26, 2016
@jchappelle
Copy link

jchappelle commented Aug 19, 2016

I'm having the same issue. The TextField I'm using is not custom it's just a regular TextField. The GuiGlobals.getInstance().requestFocus(rootNode); does the trick so I'm fine with the work around for now.

@pspeed42
Copy link
Contributor

Thanks for keeping this one on my radar, guys. So far the fix seems non-trivial but I am thinking about it.

pspeed42 added a commit that referenced this issue Dec 4, 2016
cleared when objects were removed from the scene graph.  Unfortunately,
JME provides no elegant way to handle this as we don't get any kind of
notification when an object is removed.  The only way to check is with
diligence... ie: every frame we see if the current focus hierarchy is
still intact.  This is not quite as bad as it sounds as it's just a small
index-based list iteration per frame while an object has focus.
@pspeed42 pspeed42 added this to the Lemur 1.10.1 milestone Dec 4, 2016
@pspeed42
Copy link
Contributor

pspeed42 commented Dec 4, 2016

This should be fixed now and will show up in version 1.10.

@pspeed42 pspeed42 closed this as completed Dec 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants