API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classPanel

@codexo/exojs / ui / stable

Rectangular background container with rounded corners and an optional border. The base building block for HUD boxes, dialogs, and menus - add content with `panel.addChild(...)`. The panel paints the `panel` role of its inherited theme. Constructor options and the setters below are per-panel overrides on top of it; each one repaints immediately.

52
props
63
methods
14
events
Import
import { Panel } from '@codexo/exojs'

Rectangular background container with rounded corners and an optional border. The base building block for HUD boxes, dialogs, and menus - add content with `panel.addChild(...)`.

The panel paints the `panel` role of its inherited theme. Constructor options and the setters below are per-panel overrides on top of it; each one repaints immediately.

Constructors1
new(options: PanelOptions): Panel
Methods63
_applyAnchor(containerWidth: number, containerHeight: number): void
_cascadeTheme(): void
Push a theme refresh into every themed descendant.
_collectContent(builder: RenderPlanBuilder): void
Part of the renderer SDK contract for extension renderers.
_invalidateLayout(): void
Re-lay out and repaint, then re-apply screen anchoring. This is the right invalidation for anything a skin's insets or a font size can move, and for every size change.
_invalidatePaint(): void
Repaint without re-laying out - for a change that cannot move anything, such as a colour or a state flip. Applied immediately, not batched.
_onChildListChanged(): void
Called after this container's child list changed - an insert, a removal or a reorder - once the list and the caches derived from it are consistent again. Override in containers whose own state is derived from their children, such as a layout container that re-flows them.
_onChildResized(): void
React to a child widget's size change. Layout containers override it to re-flow; the default does nothing, so a widget that does not place its children pays nothing for a descendant resize.
_onEnabledChanged(_effectiveEnabled: boolean): void
React to an effectiveEnabled change - fired whenever it flips, whether the widget's own enabled flag changed or an ancestor widget's did. Override in subclasses.
_onFocusChanged(_focused: boolean): void
React to a focus change on this widget. Override in subclasses that repaint for it; the default does nothing, so opting into tracking alone does not change how a widget looks.
_onThemeChanged(): void
React to a resolved-theme change. The default re-lays out and repaints; override to re-read skin values that are cached elsewhere first, then call super._onThemeChanged().
_relayout(): void
Re-place size-dependent content and repaint. Override in subclasses that position children; call super._relayout() to keep the repaint.
_repaint(): void
Redraw this widget's own painted surfaces for the current size and skin. Override in subclasses that draw a background.
The nearest themed ancestor's theme, or the built-in default when this node has none.
_trackFocus(): void
Follow keyboard focus on this widget, so it can paint the focused state and react in Widget._onFocusChanged. Interactive subclasses call this in their constructor; it is opt-in because subscribing allocates the focus signals, which a decorative widget would never fire.
Iterate the same frozen, cached document-order snapshot children returns - mutating the container after obtaining this iterator does not change what it yields (see children's doc comment for the full snapshot/invalidation contract).
Append one or more children to the end of the child list. Each child is detached from its previous parent (if any) before being added.
Insert child at index in the child list. The child is detached from any previous parent first. Throws if index is out of bounds, if child has already been destroy()ed, or if child is an ancestor of this container (would create a cycle). Self-as-child is a no-op. When child already belongs to this container the call is a pure reorder: the node keeps its parent, its stage and its keyboard focus.
Anchor this widget within root's screen box at anchor, offset by (offsetX, offsetY). The position is recomputed whenever the screen resizes. E.g. widget.anchorIn(scene.ui, 'bottom-right', -20, -20) pins it to the bottom-right corner with a 20px margin.
blur(): this
Release keyboard focus from this node if it currently holds it.
clearFilters(): this
collect(builder: RenderPlanBuilder, seq?: number): void
Contribute this node to the render plan under construction: skip it when it is destroyed, invisible, or outside the builder's cull rect, otherwise emit it as one plan entry. Custom node types override this to add their own admission rules and must call super.collect(builder, seq) to keep the skip semantics. seq orders the entry within its parent; omit it to append. Part of the renderer SDK contract for extension renderers.
Compute a full CollisionResponse between this shape and target. Returns null in two cases: - the shapes do not overlap, **or** - the specific shape-pair combination does not support response generation (e.g. Line against any shape, Ellipse against Ellipse or Polygon). Use intersectsWith for a universal boolean overlap check that works across all supported shape pairs.
contains(x: number, y: number): boolean
A container has no geometry of its own, so a point hits it when it hits any child. A RenderNode.hitArea replaces that union with the shape, which is how a bare layout container becomes clickable in its own right.
destroy(): void
Destroy this container and every node beneath it. Ownership is by containment: detaching a subtree only unlinks it, so the descendants' GPU-backed resources (cached textures, filters, render textures) and signal listeners would outlive the tree that owned them and leak on every scene change. Idempotent: a second call is a no-op.
focus(): this
Request keyboard focus for this node through its owning focus service.
Axis-aligned bounding box of this node in its GLOBAL-transform space. That is world space for ordinary nodes, but GROUP-LOCAL space for nodes inside an engaged RetainedContainer transform group (the group matrix is applied on the GPU, not here) - this is deliberate and matches the rendering convention. For a true world-space extent of such a node, lift this rect by the group's getWorldTransform matrix. Pass out to receive a copy you own. Without it the return value is this node's **cached** rectangle, rebuilt in place whenever the transform or the local extent changes - retaining it across frames hands you a value that silently moves. The cache is why the no-arg form does not allocate: this runs per node per frame for culling and hit-testing.
This node's untransformed extent in its own local coordinate space. Returns the LIVE internal rectangle, not a copy: it is read on hot paths (updateBounds re-reads it on every transform-dirty recompute, i.e. potentially every frame for a moving node), so copying it here would add a per-frame allocation. It is therefore typed as a ReadonlyRectangle - reads are unchanged, writes are rejected at compile time. Writing to it directly would skip the bounds/content invalidation the engine needs, leaving culling, hit-testing and retained render fragments on a stale extent. A custom Drawable that owns its own size sets it through setLocalBounds, which writes and invalidates in one step.
Return the outward-facing edge normals used by the SAT solver. The array should be cached and reused across calls.
The node's TRUE world-space transform, composed through every transform-group boundary (RetainedContainer) in the ancestor chain. getGlobalTransform deliberately stops at the nearest engaged boundary (descendants resolve group-RELATIVE transforms; the renderer multiplies the group matrix back in on the GPU), so it is the right space for rendering but the wrong one for spatial queries. Use THIS accessor whenever a real world position/orientation is needed - picking, spatial audio, physics, world-space math against nodes outside the group. Without any engaged boundary ancestor it returns the exact getGlobalTransform matrix (same instance, no extra work). With one, it lazily caches groupLocal × groupWorld and revalidates on read via version/stamp compares - including runtime space flips such as RetainedContainer's deep-barrier sub-branch escape.
Test whether this shape overlaps target using a fast boolean algorithm (no penetration depth or normal computed). Prefer this over collidesWith when only the yes/no result is needed.
invalidateCache(): this
invalidateContent(): this
Mark this node's visual content dirty without going through a standard setter - e.g. a custom Drawable subclass backed by externally mutable data (the pattern TileChunkNode in @codexo/exojs-tilemap already uses via its own _chunk.revision compare). Call this after mutating such state so the Track-B retained-plan skip does not serve a stale frame for this node.
move(x: number, y: number): this
removeChildAt(index: number): this
removeChildren(begin: number, end: number): this
Remove children in the half-open range [begin, end). Defaults to the entire child list. Throws if the range is invalid.
render(backend: RenderBackend): this
Raw rendering entry point. Direct backend access - bypasses the RenderPlan pipeline machinery. Prefer the high-level RenderingContext.render path via the owning RenderingContext wherever possible.
rotate(degrees: number): this
Set the panel's background from a colour, a texture, a region or a full descriptor; null returns it to its skin. A colour becomes a fill override on top of the skin, so the skin's corner radius and border survive it. Layout-invalidating: a nine-slice and a fill can imply different content boxes.
Override fill properties on top of the skin. Overriding a colour on a panel whose skin paints a texture switches it to a fill. Passing null drops the overrides and returns the panel to its skin.
setLocalBounds(x: number, y: number, width: number, height: number): this
Write this node's local extent and run the bounds invalidation the change implies - the node's own bounds flag, the ancestor bounds cascade, and the content-dirty stamp that keeps retained fragments from replaying the old extent. This is the only supported way to resize a node from outside getLocalBounds; the rectangle itself is handed out read-only so the invalidation cannot be forgotten. Built-in drawables (Sprite, Text, BitmapText, Mesh, ...) and custom ones alike go through here. Part of the renderer SDK contract for extension renderers.
setOrigin(x: number, y: number): this
setPosition(x: number, y: number): this
setRotation(degrees: number): this
setScale(x: number, y: number): this
setSize(width: number, height: number): this
Set the widget's layout size; triggers a redraw and re-anchors if anchored.
setSkew(x: number, y: number): this
Override parts of the inherited theme for this widget and its descendants. null clears the override. Repaints and re-lays out every widget in the subtree that the change reaches - skin insets are layout input, so a theme change is never paint-only.
updateBounds(): this
updateParentTransform(): this
updateTransform(): this
Properties52
cursor: null | string
draggable: boolean
When true and interactive is also true, this node will be automatically repositioned to follow the pointer during a drag gesture. The framework captures the pointer offset at drag-start so the node doesn't snap to the cursor position. Both interactive and draggable must be set for dragging to work - a draggable but non-interactive node will never receive pointerdown and therefore cannot start a drag.
focusable: boolean
When true, this node can receive keyboard focus - via focus, Tab traversal, or app.interaction.focus(node) - and is delivered key events through onKeyDown / onKeyUp while focused, or while any of its descendants holds focus (key events bubble up the parent chain like pointer InteractionEvents do). A Widget additionally has to be enabled: disabling one takes it out of the Tab order and rejects programmatic focus, without touching this flag.
Optional pick shape in this node's LOCAL space, replacing the bounds test contains would otherwise perform. Defaults to null. The world-space point is mapped through the inverse of the node's global transform before the shape is tested, so the region follows the node's position, rotation, scale and skew like the rendered output does - the shape itself is never re-transformed and never needs updating when the node moves. Affects picking only. Bounds, culling and rendering ignore it entirely, and because the interaction system finds candidates by their bounds, a hit area reaching outside the node's bounds is only reliably picked where the two overlap. Use it to shrink or reshape a pick region, not to grow one. The shape is the caller's: it is read live on every hit test, so mutating it in place takes effect immediately, and the node never destroys it.
name: null | string
Optional human-readable identity for this node. Defaults to null. Purely a label the engine never interprets: useful for debugging, find-by-name lookups, prefab references, and as a stable key when merging serialized state back onto an existing tree. Not required to be unique.
tabIndex: number
Tab-traversal order among focusable nodes in the same focus scope. Lower values are visited first; equal values keep document (tree) order.
The background actually painted: this panel's overrides over its skin.
borderWidth: number
Border thickness in pixels; 0 when the panel does not paint a fill.
bottom: number
Bottommost edge of the subtree - see left.
cacheAsTexture: boolean
Bake this node's subtree into a RenderTexture once and replay that texture until the subtree changes, instead of walking and drawing it every frame. Worth it for a subtree that is expensive to draw and rarely changes. The cache is invalidated by anything that moves the node's world bounds - the node's own transform included - so a node that animates re-bakes every frame and is strictly slower than not caching it at all. Setting it to false frees the texture immediately.
cacheResolution: TargetResolution
Resolution the cacheAsTexture texture is baked at, in device pixels per logical unit. 'inherit' (the default) matches the surface the cache is composited into, so enabling the cache does not soften the picture on a HiDPI display. Pin it to a number to trade sharpness for memory and bake cost - a cache is resolution² texels, so 1 on a DPR-3 phone is a ninth of the VRAM and a ninth of the fill per re-bake. Changing it invalidates the cache.
Snapshot of the current children in document order. Frozen and cached - repeated reads return the same array reference until the next structural change (addChild/removeChild/setChildIndex/ swapChildren/etc.), which invalidates it. A reference to a previous snapshot is unaffected by later changes - it keeps reflecting the child list as it was at the time of the read. Mutating methods (push, splice, ...) throw in normal (strict-mode) usage; go through addChild/removeChild instead so parent linkage, stage propagation, and bounds invalidation stay consistent.
clip: boolean
When true, descendants are geometrically clipped to clipShape. Unlike mask (which is alpha/visibility masking), clip is a hard geometric boundary: - clipShape === null - clip to this node's world-space bounds (getBounds), using the GPU scissor fast path. - clipShape is a Rectangle - clip to that world-space rectangle via scissor. - clipShape is a Geometry - clip to the geometry's silhouette via the stencil buffer (WebGL2). Only fragments inside the shape survive. Clipping wraps the node's final (filtered/masked) output and acts as a render barrier: draw commands are never reordered or batched across the clip boundary.
cornerRadius: number
Corner radius in pixels; 0 when the panel does not paint a fill.
cullable: boolean
When false, this node is never culled by the viewport check and is always considered in-view. Defaults to true.
Custom rectangle used for viewport cull intersection test. When set, replaces the default node bounds in cull checks. Set to null to restore default bounds-based culling.
destroyed: boolean
true once destroy has run on this node. A destroyed node has released its pooled resources (transform/bounds), has been unlinked from its parent, renders nothing, and must not be reused or re-attached. The render plan skips a destroyed node, so even one handed straight to a renderer as a detached root contributes nothing.
effectiveEnabled: boolean
Whether the widget responds to input right now: its own enabled flag AND every Widget ancestor's - ownEnabled && parent.effectiveEnabled. This is what interaction (e.g. Button activation) and keyboard focus actually gate on. Disabled widgets typically dim and ignore clicks, and are skipped by keyboard focus - they drop out of the Tab order and reject programmatic focus while effectively disabled. Disabling a container widget does not touch its children's OWN enabled flag - only their effective state. Re-enabling the container makes a child whose own flag was never touched effectively enabled again automatically.
enabled: boolean
The widget's own enabled flag, independent of any ancestor's. Disabling a container widget does not change this on its children - see effectiveEnabled for the value interaction and keyboard focus actually consult, and for what disabling a container does to them.
The fill overrides this panel carries, or null when it takes its skin as is.
focused: boolean
Whether this widget holds keyboard focus. Only tracked for widgets that opted in with Widget._trackFocus; a widget that never takes focus always reports false.
height: number
Rendered height of the whole subtree - see width.
interactive: boolean
isAlignedBox: boolean
left: number
Leftmost edge of the subtree in the node's global-transform space. These four edges are read straight off the aggregate bounds so they always span exactly width/height and agree with each other. They cannot be reconstructed from position and origin: origin is in local pixels and a container's own local bounds are empty, so the rendered extent comes entirely from the children.
The mask source that controls visibility of this node's render output. See MaskSource for accepted source types and their semantics. Setting to null removes any active mask. Setting a RenderNode that is this is rejected (a node cannot mask itself). Indirect cycles (a.mask = b; b.mask = a) are rejected as well: the candidate's mask chain is walked and any cycle - whether it closes on this or was already present in the chain - fails the assignment.
preserveDrawOrder: boolean
When true, material-aware overlap reordering is disabled for this node's draw-order scope. Draw commands are submitted in exact document order (after scope-local z-sorting), preserving the painter's guarantee irrespective of material compatibility or AABB safety analysis. Adjacency coalescing of consecutive same-material draws still applies; it does not change visual output order.
right: number
Rightmost edge of the subtree - see left.
rotation: number
Rotation angle in degrees. Wraps via trimRotation on assignment.
skewX: number
Horizontal skew angle in degrees. Shears the node along the X axis (positive values lean the top edge right). Combines correctly with rotation and scale.
skewY: number
Vertical skew angle in degrees. Shears the node along the Y axis (positive values lean the left edge downward). Combines correctly with rotation and scale.
The theme in effect for this node and everything below it.
top: number
Topmost edge of the subtree - see left.
uiHeight: number
Explicit layout height in pixels (not derived from children or scale).
uiWidth: number
Explicit layout width in pixels (not derived from children or scale).
visible: boolean
width: number
Rendered width of the whole subtree, in the node's global-transform space. Unlike Sprite.width - which scales an unscaled texture frame - a container has no intrinsic local size, so this reads the aggregate bounds directly. Those are already scaled, so multiplying by scale again would count it twice. Writing rescales scale.x to make the subtree render at the requested width.
x: number
y: number
zIndex: number
Events14
Fired when a pointer requests a context menu over this node - right-click, or a long-press/touch gesture that has an attributable pointer. Bubbles like the other pointer events, so a scene-wide fallback can listen on an ancestor. Carries no native event - whether the browser's own menu appears is decided by ApplicationOptions.input.allowNativeContextMenu, independently of this. Requires an attributable pointer: a pointerless keyboard-only request (the context-menu key, or Shift+F10, with no pointer ever having touched the surface - see ContextMenuRequest's doc comment) has nothing to hit-test or bubble with, so it never reaches this per-node event. It only ever reaches the engine-wide, scene-graph-independent app.input.onContextMenu.
Source