Skip to content
Back to skills

Gum Visual Events

ASecurity

Gum runtime cursor-event dispatch — how Click/Push/RollOver/etc. are raised and routed. Triggers: InteractiveGue, DoUiActivityRecursively, RoutedEventArgs, HandledActions, ClickPreview, RollOverBubbling, ClickBubbling, HasEvents, ExposeChildrenEvents, adding/bubbling a visual event.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
designgo

Works with

  • cursor
  • cli

Security analysis

A100/100

Scanned November 24, 2026

npx -y skills add vchelaru/Gum --skill gum-visual-events --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gum Visual Events?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gum Visual Events
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vchelaru-gum-visual-events/badge)](https://www.skillsdirectory.com/skills/vchelaru-gum-visual-events)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gum-visual-events
description: Gum runtime cursor-event dispatch — how Click/Push/RollOver/etc. are raised and routed. Triggers: InteractiveGue, DoUiActivityRecursively, RoutedEventArgs, HandledActions, ClickPreview, RollOverBubbling, ClickBubbling, HasEvents, ExposeChildrenEvents, adding/bubbling a visual event.
---

# Gum Visual Event Dispatch

Internals of how cursor events are raised on visuals. For the user-facing event list and "what fires when" tables, see [visual-events.md](../../../docs/code/events-and-interactivity/visual-events.md) — don't duplicate it here.

## Where it lives

| File | Role |
| --- | --- |
| `GumRuntime/InteractiveGue.cs` | All of it: event declarations, `RoutedEventArgs`/`InputEventArgs`, the `HandledActions` class, and `DoUiActivityRecursively` (the dispatch engine). |

Only types deriving from `InteractiveGue` raise events, and only when `HasEvents == true`. Forms controls layer their own events on top of these visual events (out of scope here).

## The one method that matters: `DoUiActivityRecursively`

A single recursive walk over the visual tree drives every cursor event. It descends from the root, recurses into the deepest child under the cursor first, then unwinds. Understanding the descend-then-unwind shape is the whole game.

## Three dispatch disciplines coexist (this is the non-obvious part)

The event *names* half-hide that three different routing models live side by side:

| Discipline | Order | Suppression | Events |
| --- | --- | --- | --- |
| **Tunneling** | parent → child (on the way *down*) | child skipped if a parent set `Handled` | `ClickPreview`, `PushPreview` |
| **Bubbling** | deepest child → parent (on the way *up*) | parent skipped if a descendant set `Handled` | `RollOverBubbling`, `MouseWheelScroll`, `ClickBubbling` |
| **Single-target** | fires on exactly one element | n/a — no routing | `Click`, `Push`, `DoubleClick`, `RightClick`, and most others |

These mirror WPF's Preview (tunneling) / bubbling routed-event split — same idea, same naming convention.

## Gotchas

- **Bubbling is NOT done by walking parent pointers.** It's a single shared `HandledActions` instance threaded through the recursion, combined with `RoutedEventArgs.Handled`. A handler sets `args.Handled = true`; the dispatcher copies that into a `HandledActions` flag (e.g. `HandledRollOver`), and ancestors check the flag before raising. That `HandledActions` + `Handled` pair *is* the routing machinery — reuse it to add routed events.
- **`handledByChild` is the opposite of bubbling.** Once a child "handles" (returns true), the parent's entire click/push block is skipped (`if (!handledByChild)`). That short-circuit is why `Click` is single-target: a parent container does **not** get `Click` when a child button is clicked. Bubbling events live in a separate block that runs regardless of `handledByChild`, keyed off their own `HandledActions` flag — so they and the single-target events are independent channels.
- **To make an event bubble without breaking existing behavior, add a parallel `*Bubbling` event** rather than changing the single-target one. Precedent: `RollOverBubbling` alongside `RollOver`, and `ClickBubbling` alongside `Click`. Give it its **own** `HandledActions` flag so its `Handled` only suppresses itself on ancestors and never touches single-target `Click`/`Push`.
- **A click has a push origin; rollover doesn't.** Single-target `Click` only fires where `cursor.WindowPushed == asInteractive` — you must push *and* release on the same element. So a bubbling click can't copy the `RollOverBubbling` block (which fires on anything merely under the cursor). `ClickBubbling` solves this with a `HandledActions.DidClickOccur` flag set only when a real click resolves on its target; the bubbling pass then fires on that element and the ancestors it unwinds through.
- **The walk skips subtrees with no `HasEvents` and converts the cursor position once.** `InteractiveGue.SubtreeHasEvents` caches per element until `InvalidateSubtreeCaches` (`GraphicalUiElement.SubtreeCaches.cs`) runs, so a new way to add children, show an element or change what makes an element hit-testable must call it. `CursorWorldCache` holds the world position for one `DoUiActivityRecursively` walk keyed by camera, layer and hit-test transform; call `InvalidateCursorWorldCache` after any handler that runs mid-walk and could move a camera.
- **Participation is gated.** Beyond `HasEvents`, an element's involvement depends on `ExposeChildrenEvents` and `IsEnabledRecursively`.
- **`IsInputBlocked` is not `IsEnabled`.** The walk returns early for a blocked subtree, so the cursor passes through it. Its focused-control and push handling lives in `GumCommon/Input/InputBlocker.cs`, which `FormsUtilities.Update` calls. It never touches focus or visual state.
- **A plain `ContainerRuntime` (`HasEvents = true` by default) inside a Forms control's visual swallows the control's clicks, and this is deliberate: do not "fix" it in the dispatcher.** The container claims `VisualOver` and the control's `Click`/`Push` are skipped (`handledByChild`). Every automatic fix was considered and rejected: a global "ignore containers without subscribers" breaks intentional blockers (modal backdrops, the empty-handler trick in `Window.cs`); a rule scoped to "inside a Forms visual" makes behavior depend on ancestry and current subscribers, so reparenting a container or adding one `Click +=` silently changes who gets the click; a `FULL_DIAGNOSTICS` warning can only be silenced by a dummy handler; flipping the `ContainerRuntime` default breaks existing projects. The accepted design is one explicit, local switch: set `HasEvents = false` on layout-only containers, and point users at `GetEventFailureReason<T>()` and `troubleshooting-events.md` when a control "half works".
- **`Cursor.Activity()` is edge-triggered — a second `Update()` call in the same frame collapses the press/release edge**, so Push/Click silently never fire (hover still works, it's position-only). `GetEventFailureReason` (`MonoGameGum/Input/CursorExtensions.cs`) is a structural/snapshot check and won't catch this — suspect a double `Update()` call when it reports no problem but clicks still don't fire.
- **Multiple roots are checked in reverse order, and the walk stops at the first one that claims `VisualOver`.** `GueInteractiveExtensionMethods.DoUiActivityRecursively(IList<GraphicalUiElement>, ...)` iterates the roots list back-to-front and breaks on the first root that sets `cursor.VisualOver`. A root whose top element has `HasEvents = true` and covers a large area (e.g. `Dock.Fill`) claims the cursor there unconditionally, including empty space — silently blocking every root earlier in the list, not just a same-parent sibling.
- **`InputEventArgs.InputDevice` carries the cursor**, not the underlying hardware device — single-target input events (`Click`, `Push`, etc.) pass the `ICursor` through here.
- **FRB does not share `InteractiveGue`.** It's absent from `GumCoreShared.projitems`; FlatRedBall has its own copy. Adding an event here does NOT reach FRB. If a *shared* Forms control (those ARE in FRB via `FlatRedBall.Forms.Shared.projitems`) starts subscribing to a new visual event, FRB's `InteractiveGue` must gain the same member or FRB breaks with `CS1061`.
- **`GetEventFailureReason` reads the cursor walk's cached subtree state to report a missed invalidation.** `MonoGameGum/Input/CursorExtensions.cs` is source-linked into every Skia/Stride/Silk/Unity host, so any internal it touches needs an `InternalsVisibleTo` in `GumCommon/AssemblyInfo.cs` for each of them; `Tools/verify.ps1` builds only the projects it can see changed, so build those hosts by hand after touching this file.
- **When the hovered element changes, `RollOff` on the old element is raised before `RollOn` on the new one** (#7057, WPF's leave-then-enter). Both run after the walk, in `DoUiActivityRecursively(IList<...>)`, once `cursor.VisualOver` is final; `HoverOver` and `RollOver` follow `RollOn`. `RollOnRollOffOrderTests` pins the sequence for siblings, parent/child, hidden, removed, pushed and two-cursor cases.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in design →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.