diff --git a/src/Button.cpp b/src/Button.cpp index 1a88a66..53f270c 100644 --- a/src/Button.cpp +++ b/src/Button.cpp @@ -35,10 +35,4 @@ void Button::on_paint() { painter.fill(); } -void Button::on_activation_update(ActivationUpdateEvent &event) { - if (event.activation_status() == false) { - on_click(); - } -} - } diff --git a/src/Button.hpp b/src/Button.hpp index c543970..47ebddf 100644 --- a/src/Button.hpp +++ b/src/Button.hpp @@ -1,3 +1,5 @@ +#pragma once + #include #include #include "Widget.hpp" @@ -5,8 +7,6 @@ #include "pango/pango-font.h" #include "Window.hpp" -#pragma once - namespace Raven { class Button : public Widget { @@ -15,18 +15,12 @@ public: : Widget(WidgetType::Button) , m_text(text) {} - std::function on_click { [](){} }; - void set_text(std::string text); std::string &text() { return m_text; } protected: void on_paint(); void on_init(); - void on_activation_update(ActivationUpdateEvent &event); private: - void update_color(); - void recompute_text_size(); - std::string m_text; }; diff --git a/src/Widget.cpp b/src/Widget.cpp index a8f7174..6f0bf40 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -257,6 +257,10 @@ void Widget::handle_mouse_button_event(MouseButtonEvent &event) { auto activation_update_event = ActivationUpdateEvent(update_activation_to); on_activation_update(activation_update_event); + if (update_activation_to == false) { + on_click(); + } + if (m_style->update_background()) { repaint(); } diff --git a/src/Widget.hpp b/src/Widget.hpp index 1fcb94f..2707d7f 100644 --- a/src/Widget.hpp +++ b/src/Widget.hpp @@ -44,6 +44,7 @@ public: virtual ~Widget() {}; std::function on_event { [](Event&){} }; + std::function on_click { [](){} }; bool fit_text(std::string &text);