mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibGUI: Switch focus if the currently focused widget is disabled
This commit is contained in:
parent
df6106854e
commit
644d5c5404
3 changed files with 11 additions and 0 deletions
|
@ -728,6 +728,10 @@ void Widget::set_enabled(bool enabled)
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (!m_enabled && window() && window()->focused_widget() == this) {
|
||||
window()->did_disable_focused_widget({});
|
||||
}
|
||||
|
||||
Event e(Event::EnabledChange);
|
||||
event(e);
|
||||
update();
|
||||
|
|
|
@ -927,4 +927,9 @@ void Window::focus_a_widget_if_possible(FocusSource source)
|
|||
set_focused_widget(focusable_widgets[0], source);
|
||||
}
|
||||
|
||||
void Window::did_disable_focused_widget(Badge<Widget>)
|
||||
{
|
||||
focus_a_widget_if_possible(FocusSource::Mouse);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -196,6 +196,8 @@ public:
|
|||
|
||||
void update_cursor(Badge<Widget>) { update_cursor(); }
|
||||
|
||||
void did_disable_focused_widget(Badge<Widget>);
|
||||
|
||||
protected:
|
||||
Window(Core::Object* parent = nullptr);
|
||||
virtual void wm_event(WMEvent&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue