Tuix.HitTest (tuix v0.1.6)

Copy Markdown View Source

Maps pointer coordinates to elements: which element is under the mouse.

Pure functions over the Tuix.Layout.Placed tree from the last layout, mirroring the renderer's painting model: children are searched in reverse document order (later siblings paint on top), a point only hits a descendant when it also hits every ancestor, and scroll box children are tested in content space — the pointer translated down by the scroll offset and clipped to the viewport.

Summary

Functions

The id of the innermost focusable element under {x, y}, or nil.

The id of the innermost scroll box under {x, y}, or nil.

Functions

focusable_at(placed, arg2)

@spec focusable_at(
  Tuix.Layout.Placed.t() | nil,
  {integer(), integer()}
) :: term() | nil

The id of the innermost focusable element under {x, y}, or nil.

Focusable means focusable: true with an :id prop, exactly as in Tuix.Focus. When focusables overlap, the deepest match in the last painted (topmost) subtree wins. Coordinates are 0-based cells.

scroll_box_at(placed, arg2)

@spec scroll_box_at(
  Tuix.Layout.Placed.t() | nil,
  {integer(), integer()}
) :: term() | nil

The id of the innermost scroll box under {x, y}, or nil.

The whole rect counts — border and scrollbar included, not just the inner viewport. Used by the runtime to route mouse-wheel events.