diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index 6169a2578..8bfe3a341 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -260,7 +260,7 @@ void GUI::act(float delta, const glm::uvec2& vp) { hover = nullptr; } } - if (focus) { + if (focus && focusedOnStart == focus.get()) { actFocused(); } if (focus && !focus->isFocused()) { @@ -274,6 +274,7 @@ void GUI::postAct() { postRunnables.pop(); callback(); } + focusedOnStart = focus.get(); } void GUI::draw(const DrawContext& pctx, Assets& assets) { diff --git a/src/graphics/ui/GUI.hpp b/src/graphics/ui/GUI.hpp index 7d120c9cc..97fc0ed37 100644 --- a/src/graphics/ui/GUI.hpp +++ b/src/graphics/ui/GUI.hpp @@ -72,6 +72,7 @@ namespace gui { std::shared_ptr hover; std::shared_ptr pressed; std::shared_ptr focus; + const UINode* focusedOnStart = nullptr; std::shared_ptr tooltip; std::shared_ptr rootDocument; std::unique_ptr syntaxColorScheme;