@mocanvas/editor · interface

EditorInputs

interface EditorInputs

Live pointer and modifier state.

The *ScreenPoint members are in VIEWPORT space (container-relative pixels), which is the space canvas events arrive in; *PagePoint are in page space. For a window-relative point use editor.pageToScreen(...).

Every field also has a get…() accessor. The two are the same storage: the field is what the editor's dispatch loop writes, the accessor is what application code should read. Reading through the accessor is what lets the state move behind a signal later without every call site changing — which is the whole reason the accessors exist — so new code should prefer inputs.getCurrentPagePoint() over inputs.currentPagePoint.


Methods · 20

getAccelKey(): boolean

The platform's "accelerator": metaKey on Apple platforms, ctrlKey elsewhere.

getAltKey(): boolean
getButtons(): Set<number>

Pointer buttons currently held down.

getCtrlKey(): boolean
getCurrentPagePoint(): Vec

Page-space pointer position right now.

getCurrentScreenPoint(): Vec

Viewport-space pointer position right now.

getIsDragging(): boolean

Whether the pointer has moved far enough since going down to count as a drag.

getIsEditing(): boolean
getIsPanning(): boolean
getIsPen(): boolean

Whether the active pointer is a pen.

getIsPinching(): boolean
getIsPointing(): boolean

Whether a pointer button is down.

getKeys(): Set<string>

Codes of the keys currently held down.

getMetaKey(): boolean
getOriginPagePoint(): Vec

Page-space point the current gesture started at.

getOriginScreenPoint(): Vec

Viewport-space point the current gesture started at.

getPointerVelocity(): Vec

Pointer movement per millisecond, in page units.

getPreviousPagePoint(): Vec

Page-space pointer position at the previous event.

getPreviousScreenPoint(): Vec

Viewport-space pointer position at the previous event.

getShiftKey(): boolean

Properties · 20

accelKey: boolean
altKey: boolean
buttons: Set<number>
ctrlKey: boolean
currentPagePoint: Vec
currentScreenPoint: Vec
isDragging: boolean
isEditing: boolean
isPanning: boolean
isPen: boolean
isPinching: boolean
isPointing: boolean
keys: Set<string>
metaKey: boolean
originPagePoint: Vec
originScreenPoint: Vec
pointerVelocity: Vec
previousPagePoint: Vec
previousScreenPoint: Vec
shiftKey: boolean

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.