mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
LibGUI: Add Widget::has_focus_within()
This returns true if the widget has focus, or if one of its descendant widgets does. Use this in StackWidget and TabWidget. This also fixes HackStudio crashing on startup in StackWidget, due to running before the window has a focused widget.
This commit is contained in:
@@ -88,12 +88,13 @@ void TabWidget::update_focus_policy()
|
||||
policy = FocusPolicy::NoFocus;
|
||||
set_focus_policy(policy);
|
||||
}
|
||||
|
||||
void TabWidget::set_active_widget(Widget* widget)
|
||||
{
|
||||
if (widget == m_active_widget)
|
||||
return;
|
||||
|
||||
bool active_widget_had_focus = m_active_widget && window() && (window()->focused_widget() == m_active_widget || m_active_widget->is_ancestor_of(*window()->focused_widget()));
|
||||
bool active_widget_had_focus = m_active_widget && m_active_widget->has_focus_within();
|
||||
|
||||
if (m_active_widget)
|
||||
m_active_widget->set_visible(false);
|
||||
|
||||
Reference in New Issue
Block a user