Changeset - r28170:dd5c4f66c5ea
[Not reviewed]
master
0 1 0
Peter Nelson - 13 months ago 2023-11-22 19:09:20
peter1138@openttd.org
Fix #11407: Don't steal focus from dropdown menus. (#11484)
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/window.cpp
Show inline comments
 
@@ -1393,10 +1393,11 @@ void Window::InitializeData(WindowNumber
 
	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);
0 comments (0 inline, 0 general)