diff --git a/res/rml/popup.rcss b/res/rml/popup.rcss index 0ebe05f640..f1a0f08f80 100644 --- a/res/rml/popup.rcss +++ b/res/rml/popup.rcss @@ -55,7 +55,7 @@ popup tab-bar tab { transition: decorator 0.1s linear-in-out, opacity 0.1s linear-in-out; } -popup tab-bar tab.selected { +popup tab-bar tab:selected { opacity: 1; border-bottom: 4dp #C2A42D; font-effect: glow(0dp 4dp 0dp 4dp black); diff --git a/res/rml/window.rcss b/res/rml/window.rcss index 93e891f01d..7e570bf06d 100644 --- a/res/rml/window.rcss +++ b/res/rml/window.rcss @@ -70,7 +70,7 @@ window tab-bar tab { transition: decorator 0.1s linear-in-out, opacity 0.1s linear-in-out; } -window tab-bar tab.selected { +window tab-bar tab:selected { opacity: 1; border-bottom: 4dp #C2A42D; font-effect: glow(0dp 4dp 0dp 4dp black); @@ -193,14 +193,13 @@ button { focus: auto; } -button:not(:disabled).active, button:not(:disabled):hover, button:not(:disabled):focus-visible { background-color: rgba(204, 184, 119, 20%); box-shadow: #C2A42D 0 0 0 2dp; } -button:not(:disabled).selected, +button:not(:disabled):selected, button:not(:disabled):active { opacity: 1; background-color: rgba(204, 184, 119, 40%); @@ -221,14 +220,13 @@ select-button { focus: auto; } -select-button:not(:disabled).active, select-button:not(:disabled):hover, select-button:not(:disabled):focus-visible { background-color: rgba(204, 184, 119, 20%); box-shadow: #C2A42D 0 0 0 2dp; } -select-button:not(:disabled).selected, +select-button:not(:disabled):selected, select-button:not(:disabled):active { opacity: 1; background-color: rgba(204, 184, 119, 40%); diff --git a/src/dusk/ui/button.cpp b/src/dusk/ui/button.cpp index de390893df..7a6ef1851f 100644 --- a/src/dusk/ui/button.cpp +++ b/src/dusk/ui/button.cpp @@ -29,7 +29,7 @@ void Button::set_text(const Rml::String& text) { void Button::set_selected(bool selected) { if (mProps.selected != selected) { - mRoot->SetClass("selected", selected); + mRoot->SetPseudoClass("selected", selected); mProps.selected = selected; } } diff --git a/src/dusk/ui/component.hpp b/src/dusk/ui/component.hpp index 54352aaaf3..8a50eecf44 100644 --- a/src/dusk/ui/component.hpp +++ b/src/dusk/ui/component.hpp @@ -46,6 +46,7 @@ public: } Rml::Element* root() const { return mRoot; } + bool selected() const { return mRoot->IsPseudoClassSet("selected"); } protected: static Rml::Element* append(Rml::Element* parent, const Rml::String& tag); diff --git a/src/dusk/ui/pane.cpp b/src/dusk/ui/pane.cpp index dd6ad9f27f..26da0f7c8e 100644 --- a/src/dusk/ui/pane.cpp +++ b/src/dusk/ui/pane.cpp @@ -57,6 +57,12 @@ void Pane::update() { } bool Pane::focus() { + // If there's a selected child, focus that + for (const auto& child : mChildren) { + if (child->selected() && child->focus()) { + return true; + } + } for (const auto& child : mChildren) { if (child->focus()) { return true; diff --git a/src/dusk/ui/select_button.cpp b/src/dusk/ui/select_button.cpp index 2d5035f618..93c7cc8982 100644 --- a/src/dusk/ui/select_button.cpp +++ b/src/dusk/ui/select_button.cpp @@ -47,7 +47,7 @@ bool SelectButton::focus() { void SelectButton::set_selected(bool selected) { if (mProps.selected != selected) { - mRoot->SetClass("selected", selected); + mRoot->SetPseudoClass("selected", selected); mProps.selected = selected; } }