diff --git a/src/dusk/ui/button.cpp b/src/dusk/ui/button.cpp index 7a6ef1851f..07c6b0682a 100644 --- a/src/dusk/ui/button.cpp +++ b/src/dusk/ui/button.cpp @@ -16,7 +16,7 @@ Rml::Element* createRoot(Rml::Element* parent, const Rml::String& tagName) { } // namespace Button::Button(Rml::Element* parent, Props props, const Rml::String& tagName) - : Component(createRoot(parent, tagName)) { + : FluentComponent(createRoot(parent, tagName)) { update_props(std::move(props)); } @@ -27,19 +27,12 @@ void Button::set_text(const Rml::String& text) { } } -void Button::set_selected(bool selected) { - if (mProps.selected != selected) { - mRoot->SetPseudoClass("selected", selected); - mProps.selected = selected; - } -} - Button& Button::on_pressed(ButtonCallback callback) { if (!callback) { return *this; } - listen(mRoot, Rml::EventId::Click, [callback](Rml::Event&) { callback(); }); - listen(mRoot, Rml::EventId::Keydown, [callback = std::move(callback)](Rml::Event& event) { + listen(Rml::EventId::Click, [callback](Rml::Event&) { callback(); }); + listen(Rml::EventId::Keydown, [callback = std::move(callback)](Rml::Event& event) { const auto cmd = map_nav_event(event); if (cmd == NavCommand::Confirm) { callback(); @@ -51,7 +44,6 @@ Button& Button::on_pressed(ButtonCallback callback) { void Button::update_props(Props props) { set_text(props.text); - set_selected(props.selected); mProps = std::move(props); } @@ -62,4 +54,11 @@ void ControlledButton::update() { Button::update(); } +bool ControlledButton::selected() const { + if (mIsSelected) { + return mIsSelected(); + } + return Button::selected(); +} + } // namespace dusk::ui \ No newline at end of file diff --git a/src/dusk/ui/button.hpp b/src/dusk/ui/button.hpp index d8dcd38acd..43e349e3fa 100644 --- a/src/dusk/ui/button.hpp +++ b/src/dusk/ui/button.hpp @@ -6,11 +6,10 @@ namespace dusk::ui { using ButtonCallback = std::function; -class Button : public Component { +class Button : public FluentComponent