Begin scaffolding keyboard nav

This commit is contained in:
Luke Street
2026-04-29 15:19:15 -06:00
parent 3cb7fbd030
commit d92515f0d4
15 changed files with 409 additions and 90 deletions
+23
View File
@@ -15,6 +15,20 @@ void Component::update() {
}
}
bool Component::focus() {
// Can we focus self?
if (mRoot->Focus(true)) {
return true;
}
// Otherwise, try to focus a child
for (const auto& child : mChildren) {
if (child->focus()) {
return true;
}
}
return false;
}
Rml::Element* Component::append(Rml::Element* parent, const Rml::String& tag) {
if (parent == nullptr) {
return nullptr;
@@ -35,6 +49,15 @@ void Component::listen(Rml::Element* element, Rml::EventId event,
std::make_unique<ScopedEventListener>(element, event, std::move(callback), capture));
}
bool Component::contains(Rml::Element* element) const {
for (const auto* node = element; node != nullptr; node = node->GetParentNode()) {
if (node == mRoot) {
return true;
}
}
return false;
}
void Component::clear_children() {
mChildren.clear();
while (mRoot->GetNumChildren() > 0) {