diff options
author | Max Horn | 2009-06-06 23:22:48 +0000 |
---|---|---|
committer | Max Horn | 2009-06-06 23:22:48 +0000 |
commit | f906c4e80f12ebc1c46fe8c80dfa26ff0e4d64aa (patch) | |
tree | 238ea155c88fcc9f5d18c3ee94dd5ad60c6e3d2c | |
parent | 34d097be204ca448202da34852dd4df397fcd83b (diff) | |
download | scummvm-rg350-f906c4e80f12ebc1c46fe8c80dfa26ff0e4d64aa.tar.gz scummvm-rg350-f906c4e80f12ebc1c46fe8c80dfa26ff0e4d64aa.tar.bz2 scummvm-rg350-f906c4e80f12ebc1c46fe8c80dfa26ff0e4d64aa.zip |
GUI: Tweaked the launcher so that TAB switches focus between the list and the quick search field
svn-id: r41311
-rw-r--r-- | gui/dialog.cpp | 27 | ||||
-rw-r--r-- | gui/dialog.h | 2 | ||||
-rw-r--r-- | gui/launcher.cpp | 8 |
3 files changed, 24 insertions, 13 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 964ef35b77..5e3a9a1927 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -92,10 +92,7 @@ void Dialog::open() { w = w->_next; } - if (w) { - w->receivedFocus(); - _focusedWidget = w; - } + setFocusWidget(w); } void Dialog::close() { @@ -123,6 +120,18 @@ void Dialog::reflowLayout() { GuiObject::reflowLayout(); } +void Dialog::setFocusWidget(Widget *widget) { + // The focus will change. Tell the old focused widget (if any) + // that it lost the focus. + releaseFocus(); + + // Tell the new focused widget (if any) that it just gained the focus. + if (widget) + widget->receivedFocus(); + + _focusedWidget = widget; +} + void Dialog::releaseFocus() { if (_focusedWidget) { _focusedWidget->lostFocus(); @@ -165,15 +174,7 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) { // If the click occured inside a widget which is not the currently // focused one, change the focus to that widget. if (w && w != _focusedWidget && w->wantsFocus()) { - // The focus will change. Tell the old focused widget (if any) - // that it lost the focus. - releaseFocus(); - - // Tell the new focused widget (if any) that it just gained the focus. - if (w) - w->receivedFocus(); - - _focusedWidget = w; + setFocusWidget(w); } if (w) diff --git a/gui/dialog.h b/gui/dialog.h index 018677d82b..dcc7d6fe27 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -63,6 +63,8 @@ public: bool isVisible() const { return _visible; } void releaseFocus(); + void setFocusWidget(Widget *widget); + Widget *getFocusWidget() { return _focusedWidget; } virtual void reflowLayout(); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 3b844c20b1..aebe3d4aa9 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -871,6 +871,14 @@ void LauncherDialog::loadGame(int item) { } void LauncherDialog::handleKeyDown(Common::KeyState state) { + if (state.keycode == Common::KEYCODE_TAB) { + // Toggle between the game list and the quick search field. + if (getFocusWidget() == _searchWidget) { + setFocusWidget(_list); + } else if (getFocusWidget() == _list) { + setFocusWidget(_searchWidget); + } + } Dialog::handleKeyDown(state); updateButtons(); } |