GUI: Tweaked the launcher so that TAB switches focus between the list and the quick search field

svn-id: r41311
This commit is contained in:
Max Horn 2009-06-06 23:22:48 +00:00
parent 34d097be20
commit f906c4e80f
3 changed files with 24 additions and 13 deletions

View file

@ -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)

View file

@ -63,6 +63,8 @@ public:
bool isVisible() const { return _visible; }
void releaseFocus();
void setFocusWidget(Widget *widget);
Widget *getFocusWidget() { return _focusedWidget; }
virtual void reflowLayout();

View file

@ -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();
}