Canvas Toolkit
← Class index

CObject

Core

Base class for objects that participate in the Canvas Toolkit parent-child ownership hierarchy.

import { CObject } from "canvas-toolkit-lib";

Declared members

constructor(parent?: CObject | null);

Creates an object and optionally assigns its parent. @param parent Parent object, or `null` for no parent.

parent(): CObject | null;

Returns the parent object. @returns The parent object, or `null` if the object has no parent.

children(): readonly CObject[];

Returns the direct child objects. @returns A read-only view of the direct children.

destroy(): void;

Destroys all child objects and detaches this object from its parent.

setParent(parent: CObject | null): void;

Changes the parent of this object. @param parent New parent object, or `null` to detach the object. @throws Error if the operation would create a cyclic object hierarchy.

protected detachFromParent(): void;

Detaches this object from its current parent.