Fix #11407: Don't steal focus from dropdown menus. (#11484)

wip-string
Peter Nelson 6 months ago committed by GitHub
parent 09d01bd015
commit 096da3e59f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1393,10 +1393,11 @@ void Window::InitializeData(WindowNumber window_number)
this->resize.step_width = this->nested_root->resize_x;
this->resize.step_height = this->nested_root->resize_y;
/* Give focus to the opened window unless a text box
* of focused window has focus (so we don't interrupt typing). But if the new
* window has a text box, then take focus anyway. */
if (!EditBoxInGlobalFocus() || this->nested_root->GetWidgetOfType(WWT_EDITBOX) != nullptr) SetFocusedWindow(this);
/* Give focus to the opened window unless a dropdown menu has focus or a text box of the focused window has focus
* (so we don't interrupt typing) unless the new window has a text box. */
bool dropdown_active = _focused_window != nullptr && _focused_window->window_class == WC_DROPDOWN_MENU;
bool editbox_active = EditBoxInGlobalFocus() && this->nested_root->GetWidgetOfType(WWT_EDITBOX) == nullptr;
if (!dropdown_active && !editbox_active) SetFocusedWindow(this);
/* Insert the window into the correct location in the z-ordering. */
BringWindowToFront(this, false);

Loading…
Cancel
Save