From 76b5584741a3970d9a954e233fe5ee3aa2b93a15 Mon Sep 17 00:00:00 2001 From: bodymovin Date: Wed, 14 Aug 2024 01:17:46 +0000 Subject: [PATCH] fix hovered state of group listeners fixes #7838 Diffs= 4fb978a92 fix hovered state of group listeners (#7839) e75b8fa63 Update version to macosx 11 for runtime. (#7829) 55de8286c feat: add nested text run getters and setters in Unity (#7808) Co-authored-by: hernan --- .rive_head | 2 +- lib/src/rive_core/state_machine_controller.dart | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.rive_head b/.rive_head index 81691b8a..2db670ff 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -89f9b3bd5e1f3715c9db996e0708fc4da10fe180 +4fb978a9230fc006b5e575364f062907e7dd2afe diff --git a/lib/src/rive_core/state_machine_controller.dart b/lib/src/rive_core/state_machine_controller.dart index 589229b3..6773fd14 100644 --- a/lib/src/rive_core/state_machine_controller.dart +++ b/lib/src/rive_core/state_machine_controller.dart @@ -784,6 +784,10 @@ class _ListenerGroup { _isHovered = true; } + void unhover() { + _isHovered = false; + } + void reset() { _isConsumed = false; _prevIsHovered = _isHovered; @@ -902,6 +906,17 @@ class _HitShape extends _HitComponent { if (listenerGroup.isConsumed()) { 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(); + } final isGroupHovered = canHit && listenerGroup.isHovered(); bool hoverChange = listenerGroup.prevHovered() != isGroupHovered; // If hover has changes, it means that the element is hovered for the