diff options
-rw-r--r-- | Libraries/LibGUI/Widget.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibGUI/Window.cpp | 5 | ||||
-rw-r--r-- | Libraries/LibGUI/Window.h | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp index 1b57897f4a..47aaf29646 100644 --- a/Libraries/LibGUI/Widget.cpp +++ b/Libraries/LibGUI/Widget.cpp @@ -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(); diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index 59e26f2c3c..9cf1e37ab9 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -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); +} + } diff --git a/Libraries/LibGUI/Window.h b/Libraries/LibGUI/Window.h index 93fec29e49..f4298c6986 100644 --- a/Libraries/LibGUI/Window.h +++ b/Libraries/LibGUI/Window.h @@ -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&); |