From f906c4e80f12ebc1c46fe8c80dfa26ff0e4d64aa Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 6 Jun 2009 23:22:48 +0000 Subject: GUI: Tweaked the launcher so that TAB switches focus between the list and the quick search field svn-id: r41311 --- gui/dialog.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'gui/dialog.cpp') 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) -- cgit v1.2.3