1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 02:42:42 +01:00

Fix #14756: Invalidate nested focus before widget container is cleared. (#14809)

This commit is contained in:
Cyprian Klimaszewski
2025-12-06 18:52:44 +01:00
committed by GitHub
parent 92e895a37a
commit abf8438a1b
6 changed files with 38 additions and 11 deletions

View File

@@ -3476,3 +3476,20 @@ std::unique_ptr<NWidgetBase> MakeCompanyButtonRows(WidgetID widget_first, Widget
if (hor != nullptr) vert->Add(std::move(hor));
return vert;
}
/**
* Unfocuses the focused widget of the window,
* if the focused widget is contained inside the container.
* @param parent_window Window which contains this container.
*/
void NWidgetContainer::UnfocusWidgets(Window *parent_window)
{
assert(parent_window != nullptr);
if (parent_window->nested_focus != nullptr) {
for (auto &widget : this->children) {
if (parent_window->nested_focus == widget.get()) {
parent_window->UnfocusFocusedWidget();
}
}
}
}