aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorBastien Bouclet2017-06-13 07:18:33 +0200
committerBastien Bouclet2017-06-13 07:21:34 +0200
commit9bb9c0d58eea71292d05b4e5515c48ba53d1f194 (patch)
tree93c81c355bfa3c17dea858a7e0d2b223db3400a1 /gui
parent1e64ef48e090db528ed25531c69fd569677733fd (diff)
downloadscummvm-rg350-9bb9c0d58eea71292d05b4e5515c48ba53d1f194.tar.gz
scummvm-rg350-9bb9c0d58eea71292d05b4e5515c48ba53d1f194.tar.bz2
scummvm-rg350-9bb9c0d58eea71292d05b4e5515c48ba53d1f194.zip
GUI: Focus the first 'focusable' widget when rebuilding dialogs
Fixes Trac#9838.
Diffstat (limited to 'gui')
-rw-r--r--gui/dialog.cpp18
-rw-r--r--gui/dialog.h2
-rw-r--r--gui/launcher.cpp2
-rw-r--r--gui/options.cpp2
4 files changed, 15 insertions, 9 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index d0e5755a59..24b3db4d6d 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -88,13 +88,7 @@ void Dialog::open() {
_visible = true;
g_gui.openDialog(this);
- Widget *w = _firstWidget;
- // Search for the first objects that wantsFocus() (if any) and give it the focus
- while (w && !w->wantsFocus()) {
- w = w->_next;
- }
-
- setFocusWidget(w);
+ setDefaultFocusedWidget();
}
void Dialog::close() {
@@ -142,6 +136,16 @@ void Dialog::setFocusWidget(Widget *widget) {
_focusedWidget = widget;
}
+void Dialog::setDefaultFocusedWidget() {
+ Widget *w = _firstWidget;
+ // Search for the first objects that wantsFocus() (if any) and give it the focus
+ while (w && !w->wantsFocus()) {
+ w = w->_next;
+ }
+
+ setFocusWidget(w);
+}
+
void Dialog::releaseFocus() {
if (_focusedWidget) {
_focusedWidget->lostFocus();
diff --git a/gui/dialog.h b/gui/dialog.h
index 0e06effabd..cf734a83f8 100644
--- a/gui/dialog.h
+++ b/gui/dialog.h
@@ -107,6 +107,8 @@ protected:
Widget *findWidget(const char *name);
void removeWidget(Widget *widget);
+ void setDefaultFocusedWidget();
+
void setResult(int result) { _result = result; }
int getResult() const { return _result; }
};
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index f60fecf509..3ed1236a91 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -217,7 +217,7 @@ void LauncherDialog::rebuild() {
clean();
build();
reflowLayout();
- setFocusWidget(_firstWidget);
+ setDefaultFocusedWidget();
}
void LauncherDialog::open() {
diff --git a/gui/options.cpp b/gui/options.cpp
index 8dcb199f43..3ff027620e 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -437,7 +437,7 @@ void OptionsDialog::rebuild() {
build();
reflowLayout();
_tabWidget->setActiveTab(currentTab);
- setFocusWidget(_firstWidget);
+ setDefaultFocusedWidget();
}
void OptionsDialog::open() {