Skip to content

ToolSpec

Type

ToolSpec configures a viewport tool passed to plugin:Tool.

Id

Field
Id: string

Id is the tool identifier referenced in RibbonSpec.Items.

Label

Field
Label: string

Label is the button text.

Tooltip

Field
Tooltip: string?

Tooltip is the button hover text, or nil.

Icon

Field
Icon: string?

Icon is a button icon path inside the plugin folder, or nil.

Operator

Field
Operator: string

Operator is the Id of the declared operator run on "confirm".

Keys

Field
Keys: {string}?

Keys lists up to 64 key names ("Escape", "Return", "Backspace", "Tab", "Space", "Delete", "A" to "Z", "0" to "9") sent to Modal instead of viewport shortcuts; "Escape" is always included.

Function
Modal(ctx: PluginContext, event: PluginEvent) -> ("running" | "confirm" | "cancel" | "exit", ...any)

Modal handles PluginEvents as Modal(ctx, event) while the tool is active. When the tool activates, Studio calls Modal once with "Escape" so the tool can reset its Lua state and ignores that call's return values.

Return (state, overlay, status, extra):

  • state: "running" stays active, "confirm" runs Operator, "cancel" stays active and clears wheel capture, and "exit" returns to Select.
  • overlay: Optional OverlayItem list drawn until the next return.
  • status: Optional status bar string.
  • extra: Parameter table for Operator when state is "confirm", or true to capture mouse wheel events when state is "running".