diff --git a/src/Widget.cpp b/src/Widget.cpp index d1ca0d7..c051095 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -119,6 +119,9 @@ void Widget::handle_mouse_button_event(MouseButtonEvent &event) { on_mouse_button(event); + if (m_is_active && m_window) + m_window->set_active_widget(this); + if (m_consumes_hits) event.accept(); } diff --git a/src/Window.hpp b/src/Window.hpp index 32dea83..50e38d7 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -11,6 +11,7 @@ namespace Raven { class Window { private: Widget *m_focused_widget { nullptr }; + Widget *m_active_widget { nullptr }; Widget *m_main_widget { nullptr }; Box m_current_geometry { 0, 0, 800, 600 }; Painter m_painter {}; @@ -26,6 +27,9 @@ public: Widget *get_focused_widget() { return m_focused_widget; } void set_focused_widget(Widget *focused_widget) { m_focused_widget = focused_widget; } + Widget *get_active_widget() { return m_active_widget; } + void set_active_widget(Widget *active_widget) { m_active_widget = active_widget; } + Widget *get_main_widget() { return m_main_widget; } void set_main_widget(Widget *main_widget);