isFocusKey() state reset question


31-01-2012 09:31:30


I'm using isFocusKey() to check if the user is typing something in an editBox or not, and if yes, disable the other keyboard shortcuts, to avoid, for example, un-pausing the game if someone type a P in an editBox.

It's working well, but I noticed that MyGui doesn't reset the isFocusKey to false when I click somewhere else on the Panel.
For example :
-I display the Gui, and isFocusKey() is false
-I click in an EditBox, and isFocusKey() is then true
-I click somewhere else in the panel, and the editbox is visually unfocused, but isFocusKey() stay at true
-isFocusKey() goes back to false only if I click outside of the panel.

I tried using getMouseFocusWidget(), but obtained the same result.

Anyone has any idea of what I'm doing wrong ?


31-01-2012 13:59:00

As an update, I'm experiencing the very same problem with a minimal layout, without any editBox :

<MyGUI type="Layout" version="3.2.0">
<Widget type="Window" skin="WindowCX" position="80 145 505 390" layer="Main" name="HELP_screen">

When I click with the mouse on the window, isFocusKey() goes to True, which is annoying :)
Hope someone knows of a way to fix this.


31-01-2012 20:44:39

Actually any widget might have key focus, but Edit is one of few widget that have visible key focus.
So isFocusKey return true if any widget have key input now.

So you should use getKeyFocusWidget and compare it with your edit box, or check if it have EditBox type:
if (widget->isType<MyGUI::EditBox>())


31-01-2012 20:57:24

Thanks a lot Altren for your quick answer !
Everything works like a charm now :)