Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Tool

Once a tool is registered using tiled.registerTool, it returns a tool instance. This interface extends the ToolDefinition interface with the additional properties that are available on the tool instance.

Not all properties in the ToolDefinition interface can be changed after the tool has been registered.

Hierarchy

Index

Properties

cursor

cursor: QCursor

The cursor used by this tool. This will be the cursor set on the viewport of the MapView while the tool is active.

A Qt.QCursor value can be created with tiled.cursor.

enabled

enabled: boolean

Whether this tool is enabled.

icon

icon: string

File name of the icon, or empty string when not set.

Readonly map

map: null | TileMap

Currently active tile map.

name

name: string

Name of the tool as shown on the tool bar.

preview

preview: TileMap

Get or set the preview for tile layer edits.

When getting or setting this property, a copy is made. To modify the preview, you need to assign a changed TileMap instance to this property.

To highlight areas that will be erased, use TileLayerEdit.setTile to set tiles to null, before assigning the map to the preview.

Readonly selectedTile

selectedTile: null | Tile

The last clicked tile for the active map. See also the MapEditor.currentBrush property.

statusInfo

statusInfo: string

Text shown in the status bar while the tool is active.

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

Readonly tilePosition

tilePosition: point

Mouse cursor position in tile coordinates.

toolBarActions

toolBarActions: string[]
see

ToolDefinition.toolBarActions

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

Optional deactivated

  • deactivated(): void

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

Optional mapChanged

Optional modifiersChanged

  • modifiersChanged(modifiers: number): void

Optional mouseDoubleClicked

  • mouseDoubleClicked(button: number, x: number, y: number, modifiers: number): void

Optional mouseEntered

  • mouseEntered(): void

Optional mouseLeft

  • mouseLeft(): void

Optional mouseMoved

  • mouseMoved(x: number, y: number, modifiers: number): void

Optional mousePressed

  • mousePressed(button: number, x: number, y: number, modifiers: number): void

Optional mouseReleased

  • mouseReleased(button: number, x: number, y: number, modifiers: number): void

Optional tilePositionChanged

  • tilePositionChanged(): void

Optional updateEnabledState

  • updateEnabledState(): void

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