gum-visual-events
Skill659 starsChanged 2 months agoMITView on GitHub
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.
In this repository69 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- debuggingSkill
- frb-build-verificationSkill
- frb-pixel-harnessSkill
- gum-architecture-layersSkill
- gum-bundleSkill
- gum-cliSkill
- gum-cross-platform-unificationSkill
- gum-docs-writingSkill
- gum-file-pathsSkill
- gum-forms-behaviorsSkill
- gum-forms-controlsSkill
- gum-forms-default-visualsSkill
- gum-forms-itemscontrolSkill
- gum-forms-theme-importSkill
- gum-iconsSkill
- gum-issue-creationSkill
- gum-kernsmith-integrationsSkill
- gum-layout-engineSkill
- gum-layoutSkill
- gum-localizationSkill
- gum-monogame-renderingSkill
- gum-monthly-releaseSkill
- gum-project-versioningSkill
- gum-property-assignmentSkill
- gum-raylib-renderingSkill
- gum-releaseSkill
- gum-runtime-animation-chainsSkill
- gum-runtime-bindingSkill
- gum-runtime-fontsSkill
- gum-runtime-hot-reloadSkill
- gum-runtime-syntax-versionSkill
- gum-runtime-systemmanagers-initSkill
- gum-runtime-topologySkill
- gum-runtime-variable-referencesSkill
- gum-samplesSkill
- gum-serviceSkill
- gum-source-linked-projectSkill
- gum-themingSkill
- gum-tool-animationsSkill
- gum-tool-codegenSkill
- gum-tool-copy-pasteSkill
- gum-tool-delete-logicSkill
- gum-tool-dialogsSkill
- gum-tool-errorsSkill
- gum-tool-file-watchSkill
- gum-tool-font-generationSkill
- gum-tool-import-from-gumxSkill
- gum-tool-loggingSkill
- gum-tool-outputSkill
- gum-tool-pluginsSkill
- gum-tool-save-classesSkill
- gum-tool-screenshotsSkill
- gum-tool-selectionSkill
- gum-tool-tree-viewSkill
- gum-tool-undoSkill
- gum-tool-variable-gridSkill
- gum-tool-variable-referencesSkill
- gum-tool-viewmodelsSkill
- gum-unit-testsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Only types deriving from InteractiveGue raise events, and only when HasEvents == true.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 — 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
HandledActionsinstance threaded through the recursion, combined withRoutedEventArgs.Handled. A handler setsargs.Handled = true; the dispatcher copies that into aHandledActionsflag (e.g.HandledRollOver), and ancestors check the flag before raising. ThatHandledActions+Handledpair is the routing machinery — reuse it to add routed events. handledByChildis 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 whyClickis single-target: a parent container does not getClickwhen a child button is clicked. Bubbling events live in a separate block that runs regardless ofhandledByChild, keyed off their ownHandledActionsflag — so they and the single-target events are independent channels.- To make an event bubble without breaking existing behavior, add a parallel
*Bubblingevent rather than changing the single-target one. Precedent:RollOverBubblingalongsideRollOver, andClickBubblingalongsideClick. Give it its ownHandledActionsflag so itsHandledonly suppresses itself on ancestors and never touches single-targetClick/Push. - A click has a push origin; rollover doesn't. Single-target
Clickonly fires wherecursor.WindowPushed == asInteractive— you must push and release on the same element. So a bubbling click can't copy theRollOverBubblingblock (which fires on anything merely under the cursor).ClickBubblingsolves this with aHandledActions.DidClickOccurflag 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
HasEventsand converts the cursor position once.InteractiveGue.SubtreeHasEventscaches per element untilInvalidateSubtreeCaches(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.CursorWorldCacheholds the world position for oneDoUiActivityRecursivelywalk keyed by camera, layer and hit-test transform; callInvalidateCursorWorldCacheafter any handler that runs mid-walk and could move a camera. - Participation is gated. Beyond
HasEvents, an element's involvement depends onExposeChildrenEventsandIsEnabledRecursively. - A plain
ContainerRuntime(HasEvents = trueby 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 claimsVisualOverand the control'sClick/Pushare skipped (handledByChild). Every automatic fix was considered and rejected: a global "ignore containers without subscribers" breaks intentional blockers (modal backdrops, the empty-handler trick inWindow.cs); a rule scoped to "inside a Forms visual" makes behavior depend on ancestry and current subscribers, so reparenting a container or adding oneClick +=silently changes who gets the click; aFULL_DIAGNOSTICSwarning can only be silenced by a dummy handler; flipping theContainerRuntimedefault breaks existing projects. The accepted design is one explicit, local switch: setHasEvents = falseon layout-only containers, and point users atGetEventFailureReason<T>()andtroubleshooting-events.mdwhen a control "half works". Cursor.Activity()is edge-triggered — a secondUpdate()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 doubleUpdate()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 setscursor.VisualOver. A root whose top element hasHasEvents = trueand 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.InputDevicecarries the cursor, not the underlying hardware device — single-target input events (Click,Push, etc.) pass theICursorthrough here.- FRB does not share
InteractiveGue. It's absent fromGumCoreShared.projitems; FlatRedBall has its own copy. Adding an event here does NOT reach FRB. If a shared Forms control (those ARE in FRB viaFlatRedBall.Forms.Shared.projitems) starts subscribing to a new visual event, FRB'sInteractiveGuemust gain the same member or FRB breaks withCS1061. GetEventFailureReasonreads the cursor walk's cached subtree state to report a missed invalidation.MonoGameGum/Input/CursorExtensions.csis source-linked into every Skia/Stride/Silk/Unity host, so any internal it touches needs anInternalsVisibleToinGumCommon/AssemblyInfo.csfor each of them;Tools/verify.ps1builds only the projects it can see changed, so build those hosts by hand after touching this file.- When the hovered element changes,
RollOffon the old element is raised beforeRollOnon the new one (#7057, WPF's leave-then-enter). Both run after the walk, inDoUiActivityRecursively(IList<...>), oncecursor.VisualOveris final;HoverOverandRollOverfollowRollOn.RollOnRollOffOrderTestspins the sequence for siblings, parent/child, hidden, removed, pushed and two-cursor cases.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

