wrapWithCursorReactions method
Runs the TriggerType.cursorEnter, TriggerType.cursorExit and
TriggerType.hover reactions of node when a mouse cursor enters,
leaves or moves over it.
The region covers the node's whole box, transparent parts included, and lets the nodes behind it get the cursor and taps too. Touch input fires none of these triggers.
Implementation
Widget wrapWithCursorReactions(
BuildContext context,
BaseNode node,
Widget widget,
) {
if (node is! ReactionMixin) return widget;
if (node case CanvasNode() || SpacerNode()) return widget;
List<Reaction> reactionsOf(TriggerType type) => (node as ReactionMixin)
.reactions
.where(
(reaction) =>
reaction.trigger.type == type && reaction.action.enabled,
)
.toList();
final List<Reaction> onHover = reactionsOf(TriggerType.hover);
if (onHover.isEmpty) return widget;
return MouseRegion(
opaque: false,
hitTestBehavior: HitTestBehavior.translucent,
// wrapWithReaction owns entry/exit; this region reports movement only.
onHover: onHover.isEmpty
? null
: (_) => FunctionsRepository.triggerAction(
context,
TriggerType.hover,
reactions: onHover,
),
child: widget,
);
}