1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-07 20:17:34 +00:00

LibGUI: TabWidget should not steal focus on programmatic tab switch

This matches the behavior of GUI::StackWidget.
This commit is contained in:
Andreas Kling 2020-10-30 11:34:19 +01:00
parent aef56159a8
commit 73ea191a05

View file

@ -79,12 +79,15 @@ void TabWidget::set_active_widget(Widget* widget)
if (widget == m_active_widget)
return;
bool had_focus = is_focused() || (m_active_widget && m_active_widget->is_focused());
if (m_active_widget)
m_active_widget->set_visible(false);
m_active_widget = widget;
if (m_active_widget) {
m_active_widget->set_relative_rect(child_rect_for_size(size()));
m_active_widget->set_focus(true);
if (had_focus)
m_active_widget->set_focus(true);
m_active_widget->set_visible(true);
deferred_invoke([this](auto&) {
if (on_change)