diff --git a/src/ui/ui_launcher.cpp b/src/ui/ui_launcher.cpp index d390f712..83742fae 100644 --- a/src/ui/ui_launcher.cpp +++ b/src/ui/ui_launcher.cpp @@ -6,7 +6,7 @@ #include "nfd.h" #include -std::string version_number = "v0.9.1"; +std::string version_number = "v1.0.0-rc1"; Rml::DataModelHandle model_handle; bool mm_rom_valid = false; diff --git a/src/ui/ui_renderer.cpp b/src/ui/ui_renderer.cpp index d468dcb5..89da998a 100644 --- a/src/ui/ui_renderer.cpp +++ b/src/ui/ui_renderer.cpp @@ -762,6 +762,19 @@ void recomp::register_event(UiEventListenerInstancer& listener, const std::strin listener.register_event(name, handler); } +Rml::Element* find_autofocus_element(Rml::Element* start) { + Rml::Element* cur_element = start; + + while (cur_element) { + if (cur_element->HasAttribute("autofocus")) { + break; + } + cur_element = RecompRml::FindNextTabElement(cur_element, true); + } + + return cur_element; +} + struct UIContext { struct UIRenderContext render; class { @@ -938,9 +951,12 @@ struct UIContext { } if (!mouse_is_active) { - if (!prev_focused) { - // get current focus and set to prev - prev_focused = current_document->GetFocusLeafNode(); + if (!prev_focused || !can_focus(prev_focused)) { + // Find the autofocus element in the tab chain + Rml::Element* element = find_autofocus_element(current_document); + if (element && can_focus(element)) { + prev_focused = element; + } } if (mouse_is_active_changed && prev_focused && can_focus(prev_focused)) {