Index: src/window.cpp =================================================================== --- src/window.cpp (revision 18684) +++ src/window.cpp (working copy) @@ -166,6 +166,36 @@ } /** + * Focus the next widget that accepts keyboard input. + */ +void Window::FocusNextEditWidget() +{ + uint widget_index = 0; + uint num_loops = this->nested_array_size; + + if (this->nested_focus != NULL) { + widget_index = this->nested_focus->index + 1 % this->nested_array_size; + num_loops = this->nested_array_size - 1; + } + + for (uint i = 0; i < num_loops; i++) { + const NWidgetBase *widget = this->GetWidget(widget_index); + + /* Focus next edit box */ + if (widget != NULL && widget->type == WWT_EDITBOX) { + this->SetFocusedWidget(widget_index); + break; + } + + /* Next widget index */ + widget_index++; + if (widget_index == this->nested_array_size) { + widget_index = 0; + } + } +} + +/** * Sets the enabled/disabled status of a list of widgets. * By default, widgets are enabled. * On certain conditions, they have to be disabled. @@ -1915,6 +1945,12 @@ if (_focused_window->OnKeyPress(key, keycode) == Window::ES_HANDLED) return; } + /* Focus next edit widget in the focused widget on ctrl + tab */ + if (keycode == (WKC_CTRL | WKC_TAB) && _focused_window != NULL) { + _focused_window->FocusNextEditWidget(); + return; + } + /* Call the event, start with the uppermost window, but ignore the toolbar. */ Window *w; FOR_ALL_WINDOWS_FROM_FRONT(w) { Index: src/window_gui.h =================================================================== --- src/window_gui.h (revision 18684) +++ src/window_gui.h (working copy) @@ -521,6 +521,7 @@ void UnfocusFocusedWidget(); bool SetFocusedWidget(byte widget_index); + void FocusNextEditWidget(); void HandleButtonClick(byte widget);