@mocanvas/editor · class
declare abstract class StateNodeA node in the tool state machine. Tools are trees of StateNodes: the root holds one child per tool, each tool holds its own states.
On this page
Methods · 11
constructor(editor: Editor, parent?: StateNode)enter(info: Record<string, unknown>, from: string): voidexit(info: Record<string, unknown>, to: string): voidgetCurrent(): StateNode | undefinedgetDescendant<T extends StateNode>(path: string): T | undefinedgetIsActive(): booleangetPath(): stringhandleEvent(info: EventInfo): voidDispatch an event to this node, then to its active child.
static get isLockableTool(): booleanTools can declare the interaction they perform when locked.
setCurrentToolIdMask(_mask: string | undefined): voidChange the active tool from anywhere in the tree.
transition(id: string, info?: object): thisEnter a child state.
id may be a dotted path — transition("select.idle") enters select and
then walks into its idle child, which is how a tool hands control back to
a specific state of another tool rather than to that tool's initial state.
Properties · 28
static children?: () => StateNodeConstructor[]readonly children?: Record<string, StateNode>readonly editor: Editorstatic id: stringreadonly id: stringstatic initial?: stringreadonly initial: string | undefinedstatic isLockable: booleanonCancel?(info: CancelEventInfo): voidonComplete?(info: CompleteEventInfo): voidonDoubleClick?(info: ClickEventInfo): voidonEnter?(info: Record<string, unknown>, from: string): voidonExit?(info: Record<string, unknown>, to: string): voidonInterrupt?(info: InterruptEventInfo): voidonKeyDown?(info: KeyboardEventInfo): voidonKeyRepeat?(info: KeyboardEventInfo): voidonKeyUp?(info: KeyboardEventInfo): voidonMiddleClick?(info: PointerEventInfo): voidonPointerDown?(info: PointerEventInfo): voidonPointerMove?(info: PointerEventInfo): voidonPointerUp?(info: PointerEventInfo): voidonRightClick?(info: PointerEventInfo): voidonTick?(info: TickEventInfo): voidonWheel?(info: WheelEventInfo): voidreadonly parent: StateNode | undefinedshapeType?: stringWhether the shape kind this tool creates should be kept selected after creation etc.
readonly type: StateNodeTypestatic useCoalescedEvents: booleanmocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.