Pane: Focus selected child first

This commit is contained in:
Luke Street
2026-05-01 00:56:53 -06:00
parent 0d973a497b
commit 1affefbbfc
6 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -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);
+3 -5
View File
@@ -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%);
+1 -1
View File
@@ -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;
}
}
+1
View File
@@ -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);
+6
View File
@@ -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;
+1 -1
View File
@@ -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;
}
}