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:
parent
34d097be20
commit
f906c4e80f
3 changed files with 24 additions and 13 deletions
|
@ -92,10 +92,7 @@ void Dialog::open() {
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w) {
|
setFocusWidget(w);
|
||||||
w->receivedFocus();
|
|
||||||
_focusedWidget = w;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::close() {
|
void Dialog::close() {
|
||||||
|
@ -123,6 +120,18 @@ void Dialog::reflowLayout() {
|
||||||
GuiObject::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() {
|
void Dialog::releaseFocus() {
|
||||||
if (_focusedWidget) {
|
if (_focusedWidget) {
|
||||||
_focusedWidget->lostFocus();
|
_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
|
// If the click occured inside a widget which is not the currently
|
||||||
// focused one, change the focus to that widget.
|
// focused one, change the focus to that widget.
|
||||||
if (w && w != _focusedWidget && w->wantsFocus()) {
|
if (w && w != _focusedWidget && w->wantsFocus()) {
|
||||||
// The focus will change. Tell the old focused widget (if any)
|
setFocusWidget(w);
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w)
|
if (w)
|
||||||
|
|
|
@ -63,6 +63,8 @@ public:
|
||||||
bool isVisible() const { return _visible; }
|
bool isVisible() const { return _visible; }
|
||||||
|
|
||||||
void releaseFocus();
|
void releaseFocus();
|
||||||
|
void setFocusWidget(Widget *widget);
|
||||||
|
Widget *getFocusWidget() { return _focusedWidget; }
|
||||||
|
|
||||||
virtual void reflowLayout();
|
virtual void reflowLayout();
|
||||||
|
|
||||||
|
|
|
@ -871,6 +871,14 @@ void LauncherDialog::loadGame(int item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::handleKeyDown(Common::KeyState state) {
|
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);
|
Dialog::handleKeyDown(state);
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue