@mocanvas/editor · class

ClickManager

declare class ClickManager extends EditorManager

Turns a stream of pointer presses into double-click events.

The editor's dispatch loop reports raw pointer downs and ups; deciding that two of them are one gesture needs state — when the last press was, where it was, and whether the gesture has already been reported. That state lives here rather than on Editor so a tool, a test, or an overlay can drive the same logic without one.

The manager emits down, up and settle phases for a double click, in that order: down when the second press lands, up when it is released, and settle when the window lapses with no further press. A tool that acts on down gets the responsive behaviour; one that must be sure no third press is coming waits for settle.


Methods · 4

cancelDoubleClick(): void

Restart the window: the next press begins a new gesture rather than completing the one in flight.

A tool calls this after acting on a double click that changes what is under the pointer — entering a label editor, say — so the release that follows is not read as part of the same gesture.

get clickState(): TLClickState

The gesture's current phase.

constructor(editor: Editor,
handlePointerEvent(info: PointerEventInfo): TLClickEventInfo | undefined

Feed one pointer event in.

Returns the click event it produced, or undefined when the event only moved the state machine along. The event is also handed to the emitter, so a caller that just wants the side effect can ignore the return value.


Properties · 2

emit?: TLClickEvent)

Where the synthesised click goes. Defaults to the editor's own dispatch.

lastPointerInfo: PointerEventInfo | undefined

The pointer event that opened the current gesture, if any.

Mentioned here

mocanvas 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.