1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-17 10:21:11 +00:00

Merge branch 'focus' into 'master'

Don't restore focus to hidden/unrelated buttons

Closes #5757

See merge request OpenMW/openmw!497
This commit is contained in:
Alexei Dobrohotov 2020-12-25 19:50:11 +00:00
commit c57cb09bf2

View File

@ -67,7 +67,7 @@ void KeyboardNavigation::saveFocus(int mode)
{ {
mKeyFocus[mode] = focus; mKeyFocus[mode] = focus;
} }
else else if(shouldAcceptKeyFocus(mCurrentFocus))
{ {
mKeyFocus[mode] = mCurrentFocus; mKeyFocus[mode] = mCurrentFocus;
} }
@ -93,6 +93,7 @@ void KeyboardNavigation::_unlinkWidget(MyGUI::Widget *widget)
mCurrentFocus = nullptr; mCurrentFocus = nullptr;
} }
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
void styleFocusedButton(MyGUI::Widget* w) void styleFocusedButton(MyGUI::Widget* w)
{ {
if (w) if (w)
@ -103,6 +104,7 @@ void styleFocusedButton(MyGUI::Widget* w)
} }
} }
} }
#endif
bool isRootParent(MyGUI::Widget* widget, MyGUI::Widget* root) bool isRootParent(MyGUI::Widget* widget, MyGUI::Widget* root)
{ {
@ -126,7 +128,9 @@ void KeyboardNavigation::onFrame()
if (focus == mCurrentFocus) if (focus == mCurrentFocus)
{ {
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
styleFocusedButton(mCurrentFocus); styleFocusedButton(mCurrentFocus);
#endif
return; return;
} }
@ -137,19 +141,21 @@ void KeyboardNavigation::onFrame()
focus = mCurrentFocus; focus = mCurrentFocus;
} }
// style highlighted button (won't be needed for MyGUI 3.2.3)
if (focus != mCurrentFocus) if (focus != mCurrentFocus)
{ {
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
if (mCurrentFocus) if (mCurrentFocus)
{ {
if (MyGUI::Button* b = mCurrentFocus->castType<MyGUI::Button>(false)) if (MyGUI::Button* b = mCurrentFocus->castType<MyGUI::Button>(false))
b->_setWidgetState("normal"); b->_setWidgetState("normal");
} }
#endif
mCurrentFocus = focus; mCurrentFocus = focus;
} }
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,2,3)
styleFocusedButton(mCurrentFocus); styleFocusedButton(mCurrentFocus);
#endif
} }
void KeyboardNavigation::setDefaultFocus(MyGUI::Widget *window, MyGUI::Widget *defaultFocus) void KeyboardNavigation::setDefaultFocus(MyGUI::Widget *window, MyGUI::Widget *defaultFocus)