mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Make Tab select the first widget if none is selected
This commit is contained in:
parent
5f440a29bd
commit
65a707348c
1 changed files with 20 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include <MyGUI_InputManager.h>
|
#include <MyGUI_InputManager.h>
|
||||||
#include <MyGUI_WidgetManager.h>
|
#include <MyGUI_WidgetManager.h>
|
||||||
#include <MyGUI_Button.h>
|
#include <MyGUI_Button.h>
|
||||||
|
#include <MyGUI_Gui.h>
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -13,6 +14,9 @@ namespace MWGui
|
||||||
/// Recursively get all child widgets that accept keyboard input
|
/// Recursively get all child widgets that accept keyboard input
|
||||||
void getKeyFocusWidgets(MyGUI::Widget* parent, std::vector<MyGUI::Widget*>& results)
|
void getKeyFocusWidgets(MyGUI::Widget* parent, std::vector<MyGUI::Widget*>& results)
|
||||||
{
|
{
|
||||||
|
if (!parent->getVisible() || !parent->getEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
MyGUI::EnumeratorWidgetPtr enumerator = parent->getEnumerator();
|
MyGUI::EnumeratorWidgetPtr enumerator = parent->getEnumerator();
|
||||||
while (enumerator.next())
|
while (enumerator.next())
|
||||||
{
|
{
|
||||||
|
@ -101,6 +105,22 @@ bool KeyboardNavigation::injectKeyPress(MyGUI::KeyCode key, unsigned int text)
|
||||||
bool KeyboardNavigation::switchFocus(int direction, bool wrap)
|
bool KeyboardNavigation::switchFocus(int direction, bool wrap)
|
||||||
{
|
{
|
||||||
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||||
|
|
||||||
|
if (!focus && (direction == D_Next || direction == D_Prev))
|
||||||
|
{
|
||||||
|
// if nothing is selected, select the first widget
|
||||||
|
MyGUI::VectorWidgetPtr keyFocusList;
|
||||||
|
MyGUI::EnumeratorWidgetPtr enumerator = MyGUI::Gui::getInstance().getEnumerator();
|
||||||
|
while (enumerator.next())
|
||||||
|
getKeyFocusWidgets(enumerator.current(), keyFocusList);
|
||||||
|
|
||||||
|
if (!keyFocusList.empty())
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(keyFocusList[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!focus)
|
if (!focus)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue