[Patch] reset key focus when hiding widget

scrawl

15-08-2014 02:10:45

Something I find unintuitive in MyGUI is that hidden widgets can retain key focus. I can not think of any use cases where that would be desired.

This patch resets key focus when the key focus widget is hidden, similar to how it is already done for mouse focus.


Index: MyGUIEngine/src/MyGUI_Widget.cpp
===================================================================
--- MyGUIEngine/src/MyGUI_Widget.cpp (revision 5304)
+++ MyGUIEngine/src/MyGUI_Widget.cpp (working copy)
@@ -976,6 +976,8 @@

if (!value && InputManager::getInstance().getMouseFocusWidget() == this)
InputManager::getInstance()._resetMouseFocusWidget();
+ if (!value && InputManager::getInstance().getKeyFocusWidget() == this)
+ InputManager::getInstance().resetKeyFocusWidget();
}

void Widget::setEnabled(bool _value)

Pull request: https://github.com/MyGUI/mygui/pull/4

Altren

15-08-2014 12:37:50

Merged.