diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index 0923b0998..dc6dd6ac5 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -146,11 +146,18 @@ void GUI::actMouse(float delta, const CursorState& cursor) { } this->hover = hover; auto node = hover; + while (node) { - if (mouseOver.find(hover) != mouseOver.end()) { - break; + if (std::find_if( + mouseOver.begin(), + mouseOver.end(), + [&hover](const std::weak_ptr& weak) { + auto locked = weak.lock(); + return locked && locked == hover; + }) != mouseOver.end()) { + break; } - mouseOver.insert(node); + mouseOver.push_back(node); node->setMouseOver(true); auto parent = node->getParent(); if (parent) { @@ -159,12 +166,14 @@ void GUI::actMouse(float delta, const CursorState& cursor) { } for (auto it = mouseOver.begin(); it != mouseOver.end(); ) { - auto node = *it; - if (node->isInside(cursor.pos)) { - ++it; - continue; + auto node = it->lock(); + if (node) { + if (node->isInside(cursor.pos)) { + ++it; + continue; + } + node->setMouseOver(false); } - node->setMouseOver(false); it = mouseOver.erase(it); } diff --git a/src/graphics/ui/GUI.hpp b/src/graphics/ui/GUI.hpp index 8a12c3cd4..5d6140c27 100644 --- a/src/graphics/ui/GUI.hpp +++ b/src/graphics/ui/GUI.hpp @@ -81,7 +81,7 @@ namespace gui { std::unique_ptr uicamera; std::shared_ptr menu; std::queue postRunnables; - std::set> mouseOver; + std::vector> mouseOver; PageLoaderFunc pagesLoader;