Base class for every widget: a retained openfl.display.Sprite that repaints ONLY when invalidated (no per-frame update). Subclasses override render() and read UITheme / UILocale there, so theme and locale swaps re-skin the whole tree via UIRoot.invalidateAll.

Pointer correctness is built in: pressed is only set by a press that starts on this widget, and click() fires only when the matching release also lands on it (see UIPointer). Drags use beginCapture() to receive exclusive onDragMove/onDragEnd callbacks.

Construction flavors:

  • interactive = true — hover/press/click handling (leaf widgets)
  • interactive = false, blocking = true — a passive surface that still swallows pointer hits (panels, backdrops); children stay interactive
  • interactive = false, blocking = false — pure layout group, pointer-transparent

Constructor

@:value({ blocking : true, interactive : true })new(interactive:Bool = true, blocking:Bool = true)

Variables

@: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)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).

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

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

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

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

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

Fired on a right mouse press over this widget (context menus).

Methods

dispose():Void

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

invalidate():Void

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

render():Void

Repaints immediately. Subclasses draw their full visual state here.

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