Generic tree node with parent/child relationships and hierarchy change signals.
The type parameter represents the concrete node type stored in the hierarchy. This is the base structural container used by higher-level scene and markup objects in the engine.
The class is intentionally small: - it manages parent and child ownership - it provides tag-based lookup helpers - it emits hierarchy change signals
It does not define transform, rendering, or update behavior on its own.
Constructor
Variables
read onlychildAdded:Signal<(child:T) ‑> Void> = new s.shortcut.signals.Signal([])
Fired when a direct child is added.
read onlychildRemoved:Signal<(child:T) ‑> Void> = new s.shortcut.signals.Signal([])
Fired when a direct child is removed.
read onlychildren:ObjectList<T>
Direct child nodes.
The list manages ownership: adding a node here updates its parent, and removing it detaches it.
read onlydescendantAdded:Signal<(descendant:T) ‑> Void> = new s.shortcut.signals.Signal([])
Fired when any descendant is added anywhere below this node.
read onlydescendantRemoved:Signal<(descendant:T) ‑> Void> = new s.shortcut.signals.Signal([])
Fired when any descendant is removed anywhere below this node.
parent:T
Parent node or null if this node is detached.
Assigning this field re-parents the node. Most code should use
setParent, removeParent,
addChild, or removeChild
instead of mutating internal storage directly.
read onlyparentChanged:Signal<(previous:T) ‑> Void> = new s.shortcut.signals.Signal([])
Fired when the parent changes.
tag:String
Optional application-defined tag used for lookup.
Tags are not required to be unique. Methods such as
getChild, getChildren, and
findChild use this field for simple structural
queries.
Methods
addChild(value:T):T
Adds a direct child.
If the child already belongs to another parent, it is re-parented.
Parameters:
value | Child node to add. |
|---|
Returns:
The added child or null if it is already present.
findChild(tag:String):T
Searches the full descendant tree for the first node with the given tag.
Search order is depth-first in child order.
Parameters:
tag | Tag to match. |
|---|
Returns:
The found descendant or null.
getChild(tag:String):T
Returns the first direct child with the given tag.
This only checks direct children and does not recurse into descendants.
Parameters:
tag | Tag to match. |
|---|
Returns:
The found child or null.
getChildren(tag:String):Array<T>
Returns all direct children with the given tag.
This only checks direct children and does not recurse into descendants.
Parameters:
tag | Tag to match. |
|---|
Returns:
Matching direct children.
removeChild(value:T):Bool
Removes a direct child.
Parameters:
value | Child node to remove. |
|---|
Returns:
true if the child was removed.
setParent(value:T):Void
Sets the parent node.
This is equivalent to adding the node to value.children.
Parameters:
value | New parent node. |
|---|
traverse(f:T ‑> Void):T
Traverses all descendants depth-first and applies a callback.
The callback receives each descendant, not the root node itself.
Parameters:
f | Callback invoked for each descendant. |
|---|
Returns:
This node.