Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ToolDefinition

This interface can be implemented to define a custom tool. See tiled.registerTool for an example.

The mouse button parameters are numbers from the Qt::MouseButton enum. They can be accessed like Qt.LeftButton.

Whenever there is a keyboard modifiers parameter, they are given as flags from the Qt::KeyboarModifiers enum, available similarly like Qt.ShiftModifier.

Hierarchy

  • ToolDefinition

Index

Properties

Optional icon

icon: string

File name of an icon. If set, the icon is shown on the tool bar and the name becomes the tool tip.

name

name: string

Name of the tool as shown on the tool bar.

Optional targetLayerType

targetLayerType: number

The target layer type for which this tool should be enabled. A convenient alternative to overriding updateEnabledState.

The value can be any combination of the layer types Layer.TileLayerType, Layer.ObjectGroupType, Layer.ImageLayerType and Layer.GroupLayerType.

since

1.10

Optional toolBarActions

toolBarActions: string[]

List of action IDs, specifying the actions that should be added to the tool-specific tool bar.

Separators can be added to this tool bar by adding "-" in the list of actions.

The actions need to be registered using tiled.registerAction().

since

1.9

Optional usesSelectedTiles

usesSelectedTiles: boolean

Whether this tool uses the currently selected tiles. This defaults to false.

When set to false and the currently selected tiles change while this tool is active, the Stamp Brush is automatically activated. Set this property to true to keep this tool active.

since

1.8

Optional usesWangSets

usesWangSets: boolean

Whether this tool works with Wang sets. This defaults to false.

When set to false and a Wang color is clicked while this tool is active, the Terrain Brush is automatically activated. Set this property to true to keep this tool active.

since

1.8

Methods

Optional activated

  • activated(): void
  • Called when the tool was activated.

Optional deactivated

  • deactivated(): void
  • Called when the tool was deactivated.

Optional keyPressed

  • keyPressed(key: number, modifiers: number): void
  • Called when a key was pressed while the tool was active.

    The keys are defined by numbers from the Qt::Key enum. They can be accessed like Qt.Key_Return.

Optional languageChanged

  • languageChanged(): void
  • Called when the language was changed.

Optional mapChanged

  • Called when the active map was changed.

Optional modifiersChanged

  • modifiersChanged(modifiers: number): void
  • Called when the active modifier keys changed.

Optional mouseDoubleClicked

  • mouseDoubleClicked(button: number, x: number, y: number, modifiers: number): void
  • Called when a mouse button was double-clicked.

Optional mouseEntered

  • mouseEntered(): void
  • Called when the mouse entered the map view.

Optional mouseLeft

  • mouseLeft(): void
  • Called when the mouse left the map view.

Optional mouseMoved

  • mouseMoved(x: number, y: number, modifiers: number): void
  • Called when the mouse position in the map scene changed.

Optional mousePressed

  • mousePressed(button: number, x: number, y: number, modifiers: number): void
  • Called when a mouse button was pressed.

Optional mouseReleased

  • mouseReleased(button: number, x: number, y: number, modifiers: number): void
  • Called when a mouse button was released.

Optional tilePositionChanged

  • tilePositionChanged(): void
  • Called when the hovered tile position changed.

Optional updateEnabledState

  • updateEnabledState(): void
  • Called when the map or the current layer changed.

Optional updateStatusInfo

  • updateStatusInfo(): void
  • Defining this function is necessary to suppress the default updating of the status bar text.

    This function is called automatically when the hovered tile position changed, but statusInfo can be changed in any other function as well.

Generated using TypeDoc