mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2024-11-07 15:15:05 +01:00
Fix issue where an invalid element can take focus if mouse movement happens immediately
This commit is contained in:
parent
fab4f66903
commit
8a70b2313e
@ -6,7 +6,7 @@
|
|||||||
#include "nfd.h"
|
#include "nfd.h"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
std::string version_number = "v0.9.1";
|
std::string version_number = "v1.0.0-rc1";
|
||||||
|
|
||||||
Rml::DataModelHandle model_handle;
|
Rml::DataModelHandle model_handle;
|
||||||
bool mm_rom_valid = false;
|
bool mm_rom_valid = false;
|
||||||
|
@ -762,6 +762,19 @@ void recomp::register_event(UiEventListenerInstancer& listener, const std::strin
|
|||||||
listener.register_event(name, handler);
|
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 UIContext {
|
||||||
struct UIRenderContext render;
|
struct UIRenderContext render;
|
||||||
class {
|
class {
|
||||||
@ -938,9 +951,12 @@ struct UIContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!mouse_is_active) {
|
if (!mouse_is_active) {
|
||||||
if (!prev_focused) {
|
if (!prev_focused || !can_focus(prev_focused)) {
|
||||||
// get current focus and set to prev
|
// Find the autofocus element in the tab chain
|
||||||
prev_focused = current_document->GetFocusLeafNode();
|
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)) {
|
if (mouse_is_active_changed && prev_focused && can_focus(prev_focused)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user