diff options
-rw-r--r-- | gui/dialog.cpp | 18 | ||||
-rw-r--r-- | gui/dialog.h | 2 | ||||
-rw-r--r-- | gui/launcher.cpp | 2 | ||||
-rw-r--r-- | gui/options.cpp | 2 |
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() { |