Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClickCreatingTool

Hierarchy

  • Tool
    • ClickCreatingTool

The ClickCreatingTool lets the user create a node by clicking where they want the new node to be. By default a double-click is required to start this tool; set isDoubleClick to false if you want a single-click to create a node.

This tool is a standard mouse-up tool, the ToolManager.clickCreatingTool. However, it will not be able to start running unless you have set the archetypeNodeData property to an object that can be copied and added to the diagram's model.

If you set isGridSnapEnabled to true, newly created parts will be snapped to points on a grid.

This tool does not utilize any Adornments or tool handles. This tool does conduct a transaction when inserting the new node.

Index

Constructors

constructor

Properties

archetypeNodeData : ObjectData | null

  • Gets or sets a data object that will be copied and added to the diagram's model each time this tool executes. The default value is null. The value must be non-null for this tool to be able to run. Setting this property does not raise any events.

isDoubleClick : boolean

  • Gets or sets whether a double click rather than a single-click is required to insert a new Part at the mouse-up point. The default value is true -- only a double-click will cause a node to be created. Setting this property does not raise any events.

isGridSnapEnabled : boolean

  • Gets or sets whether the ClickCreatingTool snaps object sizes to the diagram's background grid during creation. By default this property is false. Setting this property does not raise any events.

    since

    2.0

Methods

Virtual Override canStart

  • canStart(): boolean
  • This tool can run when the diagram is not read-only and supports creating new nodes, and when there has been a click (or double-click if isDoubleClick is true) in the background of the diagram (not on a Part), and archetypeNodeData is an object that can be copied and added to the model.

    This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Returns boolean

Override doMouseUp

  • doMouseUp(): void
  • Upon a click, call insertPart and stop this tool.

    Returns void

Virtual insertPart

  • Create a node by adding a copy of the archetypeNodeData object to the diagram's model, assign its Part.location to be the given point, and select the new part.

    This starts and commits a transaction and also raises the "PartCreated" DiagramEvent. The actual part that is added to the diagram may be a Part, a Node, or even a Group, depending on the properties of the archetypeNodeData and the type of the template that is copied to create the part.

    This method may be overridden, although it is usually much easier to just set archetypeNodeData. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Parameters

    • loc: Point

      a Point in document coordinates.

    Returns Part

    the newly created Part, or null if it failed.