A hierarchical, expandable tree. It reuses UIList's virtualization: the tree keeps a mutable node model and flattens the currently-visible nodes (collapsed subtrees excluded) into a flat array, which feeds the list as its provider. So a 100k-node tree still only instantiates the handful of rows on screen, exactly like UIList.

Rows indent by depth and draw an expand/collapse chevron for parent nodes; clicking the chevron toggles the branch, clicking elsewhere selects the row (Up/Down + Enter work through the underlying list). Build the model with UITreeNodes and hand the roots to setRoots.

Constructor

@:value({ rowHeight : 0 })new(width:Float, height:Float, rowHeight:Float = 0)

Parameters:

width

layout width

height

visible viewport height

rowHeight

base (unscaled) row height; 0 picks the platform default

Variables

read onlylist:UIList

The backing virtualized list (its selection/scroll drive the tree).

read onlyselectedNode:UITreeNode

The currently selected node, or null.

@:value(null)onActivate:UITreeNode ‑> Void = null

Fired on double click / Enter (leaves only; a parent toggles instead).

@:value(null)onNodeRightClick:(UITreeNode, Float, Float) ‑> Void = null

Fired on a right-click (or touch long-press) of a node, for a context menu. The node is selected first, so selectedNode matches; the coordinates are in stage space.

@:value(null)onSelect:UITreeNode ‑> Void = null

Fired when the selected node changes.

@:value(null)onToggle:(UITreeNode, Bool) ‑> Void = null

Fired when a branch expands (true) or collapses (false).

Methods

collapseAll():Void

Collapses every branch, then rebuilds the visible window.

expandAll():Void

Expands every branch, then rebuilds the visible window.

inlinerefresh():Void

Rebinds the visible rows after mutating node labels in place.

setRoots(roots:Array<UITreeNode>):Void

Replaces the whole model and rebuilds the visible window.

Parameters:

roots

the top-level nodes

Inherited Variables

Defined by UIComponent

@:value(true)enabled:Bool = true

Disabled widgets ignore the pointer and typically render dimmed.

@:value(0)read onlyh:Float = 0

Layout height in UI units.

@:value(MouseCursor.BUTTON)hoverCursor:MouseCursor = MouseCursor.BUTTON

Native cursor while hovering (interactive widgets; null keeps the arrow).

@:value(false)read onlyhovered:Bool = false

true while the cursor is over this widget.

@:value(false)longPressable:Bool = false

Opts a subclass that overrides onRightPress (without setting onRightClick) into long-press-as-right-click on touch. Widgets with onRightClick set are included automatically.

@:value(null)onClick:() ‑> Void = null

Fired on a completed click (press + release on this widget). Requires an interactive widget.

@:value(null)onHover:() ‑> Void = null

Fired when the cursor first enters this widget (hover-driven descriptions/previews). Interactive widgets only.

@:value(null)onRightClick:() ‑> Void = null

Fired on a right mouse press over this widget (context menus). Only interactive widgets receive pointer events, so this never fires on passive widgets like UILabel/UIPanel — attach it to a UIButton (or another interactive widget) instead. On touch, a long-press fires the same path (see UIRoot.longPressMs).

@:value(false)read onlypressed:Bool = false

true while a press that started here is held.

@:value(null)tooltip:String = null

Optional tooltip text (already-localized or a fixed string).

@:value(null)tooltipShortcut:String = null

Optional right-aligned shortcut hint rendered in the tooltip.

@:value(0)read onlyw:Float = 0

Layout width in UI units (independent of DisplayObject's content-derived width).

Inherited Methods

Defined by UIComponent

dispose():Void

Tears the widget down: listeners, pointer references, children, parent link.

invalidate():Void

Schedules a repaint for the next frame (cheap; deduplicated).

resize(width:Float, height:Float):Void

Sets the layout size and repaints when it changed.

Parameters:

width

the new layout width in UI units

height

the new layout height in UI units