aboutsummaryrefslogtreecommitdiff
path: root/gui/dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/dialog.cpp')
-rw-r--r--gui/dialog.cpp27
1 files changed, 14 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)