Skip to content

Vibe coding a plugin? 😎 Teach your agent Modlumi first. Works with Claude Code, Codex, Cursor and more.

ToolDefinition

An interactive tool a plugin adds, which the user picks from the Extensions menu or the toolbar like a built-in tool. See PluginContext.registerTool.

Handlers run once per frame for what happened since the last one, in order, and may edit the model inside Model.operation. They must be synchronous. After them, draw describes the preview, which shows until the next run.

optional icon?: string

An SVG file in the plugin folder, as for CommandDefinition.icon.


id: string

Identifies the tool within its plugin: letters, digits, dots, dashes or underscores.


optional shortcut?: string

A keyboard shortcut, as for CommandDefinition.shortcut.


optional snap?: boolean

Whether the pointer snaps and shows inferences like the drawing tools; true by default. Tools that only pick what is under the pointer turn it off, and their events have no point.


optional tip?: string


title: string

The tool’s name, in its menu entry, tooltip and the status bar.


optional toolbar?: boolean

Also show the tool in the plugin’s toolbar group. Needs an icon.

optional activate(event): void

ToolEvent

void


optional deactivate(event): void

ToolEvent

void


optional draw(view): void

Describes the preview drawn over the model.

ToolView

void


optional onCancel(reason, event): void

Escape, picking another tool or undo ended the gesture.

NonNullable<"escape" | "reselected" | "history" | "focusLost" | null>

ToolEvent

void


optional onDoubleClick(event): void

ToolEvent

void


optional onKeyDown(event): void

ToolEvent

void


optional onKeyUp(event): void

ToolEvent

void


optional onMouseDown(event): void

The left button went down; the right button opens the context menu instead.

ToolEvent

void


optional onMouseMove(event): void

ToolEvent

void


optional onMouseUp(event): void

ToolEvent

void


optional onValue(text, event): void

The user typed in the measurement box and pressed Enter. Read lengths with Model.parseLength.

string

ToolEvent

void


optional options(ui): void

Draws the tool’s options, in a card over the top left of the viewport while the tool is selected, with the same widgets as panels. Changing an option keeps the tool’s gesture going, and the preview draws again.

Ui

void


optional resume(event): void

ToolEvent

void


optional suspend(event): void

A navigation tool, such as Orbit with the middle button, takes over for a while.

ToolEvent

void