From 7f26843dc3f651845d47fdfeb02f7a320f7baae1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 27 Jun 2014 18:18:58 +0200 Subject: [PATCH] Reset key focus when the key focus widget is hidden (Fixes #1568) --- apps/openmw/mwgui/windowbase.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index cc18e6694e..4af0afc1f6 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -21,6 +21,17 @@ void WindowBase::setVisible(bool visible) open(); else if (wasVisible && !visible) close(); + + // This is needed as invisible widgets can retain key focus. + if (!visible) + { + MyGUI::Widget* keyFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); + while (keyFocus != mMainWidget && keyFocus != NULL) + keyFocus = keyFocus->getParent(); + + if (keyFocus == mMainWidget) + MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(NULL); + } } bool WindowBase::isVisible()