GUI: Focus the first 'focusable' widget when rebuilding dialogs

Fixes Trac#9838.
This commit is contained in:
Bastien Bouclet 2017-06-13 07:18:33 +02:00
parent 1e64ef48e0
commit 9bb9c0d58e
4 changed files with 15 additions and 9 deletions

View file

@ -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();