DWVv0.37.0

ToolboxController

Source: toolboxController.js:28

Toolbox controller.


Constructor

new ToolboxController( toolList: object, rootDocument?: DocumentFragment, ): ToolboxController

Parameters

  • toolList (object) — The list of tool objects.
  • rootDocument (DocumentFragment, optional) — Optional root document to listen to for keyboard shortcuts, defaults to document.

Instance Methods

init()

Initialise.

enableShortcuts(flag: boolean)

Enable or disable shortcuts. The 'init' methods enables shortcuts by default. Call this method after init to disable shortcuts.

Shortcuts are keydown events listened to on the root document in the bubbling phase and passed to the selected tool. Events with a prevented default or coming from editable elements (input, select, text area, content editable) are ignored.

Parameters

  • flag (boolean) — True to enable shortcuts.

getToolList(): Array

Get the tool list.

Returns

  • Array — The list of tool objects.

hasTool(name: string): boolean

Check if a tool is in the tool list.

Parameters

  • name (string) — The name to check.

Returns

  • boolean — The tool list element for the given name.

getSelectedTool(): object

Get the selected tool.

Returns

  • object — The selected tool.

getSelectedToolEventHandler( eventType: string, ): EventListener | undefined

Get the selected tool event handler.

Parameters

  • eventType (string) — The event type, for example mousedown, touchstart...

Returns

  • EventListener | undefined — The event handler, undefined if no tool is selected.

setSelectedTool(name: string)

Set the selected tool.

Parameters

  • name (string) — The name of the tool.

setToolFeatures(list: object)

Set the selected tool live features.

Parameters

  • list (object) — The list of features.

bindLayerGroup( layerGroup: LayerGroup, layer: ViewLayer | DrawLayer, )

Listen to layer interaction events.

Parameters