monogame-ui-interaction

Installation
SKILL.md

MonoGame UI Interaction — Hit Testing & Event Bubbling

This skill covers how pointer input (mouse, touch) connects to UI elements. For input polling fundamentals (prev/curr state), see monogame-input. For keyboard/gamepad focus, see monogame-ui-focus. For complete code templates, read references/ui-interaction.md.

Assumed Contract

UIElement.Bounds must be an up-to-date absolute screen Rectangle before hit testing runs. If Bounds is empty (Rectangle.Empty or default), no element will be hit. Always run the layout Arrange pass (from monogame-ui-layout) before processing pointer input.

Hit testing reads MouseState from monogame-input's prev/curr state pattern — do not poll Mouse.GetState() a second time inside UI update code.

Hit Testing: DFS Reverse Traversal

The visual tree is painted parent → children (painter's algorithm). The child drawn last appears on top. Therefore, hit testing must check children in reverse order (last drawn = first tested):

Installs
14
GitHub Stars
2
First Seen
May 20, 2026
monogame-ui-interaction — alca259/monogame-skills