fix hovered state of group listeners fixes #7838 Diffs= 4fb978a92 fix hovered state of group listeners (#7839) Co-authored-by: hernan <hernan@rive.app>
diff --git a/.rive_head b/.rive_head index 1b18626..2db670f 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -e75b8fa633a4f8eb102e669ac1308b1d1151fed1 +4fb978a9230fc006b5e575364f062907e7dd2afe
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp index dcc6ff6..e549a1a 100644 --- a/src/animation/state_machine_instance.cpp +++ b/src/animation/state_machine_instance.cpp
@@ -432,6 +432,7 @@ void consume() { m_isConsumed = true; } // void hover() { m_isHovered = true; } + void unhover() { m_isHovered = false; } void reset() { m_isConsumed = false; @@ -547,6 +548,18 @@ { continue; } + // Because each group is tested individually for its hover state, a group + // could be marked "incorrectly" as hovered at this point. + // But once we iterate each element in the drawing order, that group can + // be occluded by an opaque target on top of it. + // So although it is hovered in isolation, it shouldn't be considered as + // hovered in the full context. + // In this case, we unhover the group so it is not marked as previously + // hovered. + if (!canHit && listenerGroup->isHovered()) + { + listenerGroup->unhover(); + } bool isGroupHovered = canHit ? listenerGroup->isHovered() : false; bool hoverChange = listenerGroup->prevHovered() != isGroupHovered;