UNPKG

gojs

Version:

Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams

759 lines 77.8 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>DraggingTool | GoJS API</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../../assets/css/bootstrap.min.css"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <!-- non-fixed navbar --> <nav id="non-fixed-nav" class="navbar navbar-inverse navbar-top"> <div class="container-fluid"> <div class="navbar-header"> <div class="navheader-container"> <div class="navheader-collapse" data-toggle="collapse" data-target="#navbar"> <a id="toplogo" class="navbar-brand" href="../../index.html">GoJS</a> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> </div> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <li><a href="../../index.html">Home</a></li> <li><a href="../../learn/index.html">Learn</a></li> <li><a href="../../samples/index.html">Samples</a></li> <li><a href="../../intro/index.html">Intro</a></li> <li><a href="../../api/index.html" target="api">API</a></li> <li><a href="https://www.nwoods.com/components/evalform.htm">Register</a></li> <li><a href="../../download.html">Download</a></li> <li><a href="https://forum.nwoods.com/c/gojs">Forum</a></li> <li><a href="https://www.nwoods.com/contact.html" onclick="ga('send','event','Outbound Link','click','contact');">Contact</a></li> <li class="buy"><a href="https://www.nwoods.com/sales/index.html" onclick="ga('send','event','Outbound Link','click','buy');">Buy</a></li> <li class="activate"><a href="https://www.nwoods.com/app/activate.aspx?sku=gojs">Activate</a></li> </ul> </div><!--/.nav-collapse --> </div> </nav> <div class="tsd-page-header"> <div class="tsd-page-toolbar"> <div class="container-fluid plr15"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">GoJS API</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container-fluid plr15"> <div class="top-copyright"> <!--<b>GoJS</b>&reg; Diagramming Components<br/>version &lt;br/&gt;version 2.1.18 for TypeScript/HTML<br/>by <a href="https://www.nwoods.com/">Northwoods Software&reg;</a>--> <b>GoJS</b>&reg; Diagramming Components<br/>version 2.1.18<br/>by <a href="https://www.nwoods.com/">Northwoods Software&reg;</a> </div> <div> <h1>Class DraggingTool</h1> </div> </div> </div> </div> </header> <div class="container-fluid container-main plr15"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <a href="Tool.html" class="tsd-signature-type">Tool</a> <ul class="tsd-hierarchy"> <li> <span class="target">DraggingTool</span> <ul class="tsd-hierarchy"> <li> <a href="GuidedDraggingTool.html" class="tsd-signature-type">GuidedDraggingTool</a> </li> <li> <a href="NonRealtimeDraggingTool.html" class="tsd-signature-type">NonRealtimeDraggingTool</a> </li> </ul> </li> </ul> </li> </ul> </section> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <p>The DraggingTool is used to move or copy selected parts with the mouse. This sets the <a href="Part.html#location">Part.location</a> property; you may want to save the location to the model by using a TwoWay <a href="Binding.html">Binding</a> on the &quot;location&quot; property in your Parts/Nodes/Groups templates.</p> <p>Dragging the selection moves parts for which <a href="Part.html#canMove">Part.canMove</a> is true. If the user holds down the Control key (Option key on Mac), this tool will make a copy of the parts being dragged, for those parts for which <a href="Part.html#canCopy">Part.canCopy</a> is true.</p> <p>When the drag starts it calls <a href="DraggingTool.html#computeEffectiveCollection">computeEffectiveCollection</a> to find the actual collection of <a href="Part.html">Part</a>s to be dragged. Normally this collection includes not only the <a href="Diagram.html#selection">Diagram.selection</a>, but also parts that belong to those selected parts, such as members of groups. If <a href="DraggingTool.html#dragsTree">dragsTree</a> is true, the effective collection also includes all of the nodes and links that constitute the subtree starting from selected nodes. The result of <a href="DraggingTool.html#computeEffectiveCollection">computeEffectiveCollection</a> is not a <a href="Set.html">Set</a> but a <a href="Map.html">Map</a> which remembers the original <a href="Part.html#location">Part.location</a> for all of the dragged parts. This map is saved as the value of <a href="DraggingTool.html#draggedParts">draggedParts</a>.</p> <p>During the drag if the user holds down the Control/Option key this tool makes a copy of the <a href="DraggingTool.html#draggedParts">draggedParts</a> and proceeds to drag it around. (It only copies the <a href="Diagram.html#selection">Diagram.selection</a>, not the whole effective collection, if <a href="DraggingTool.html#copiesEffectiveCollection">copiesEffectiveCollection</a> is false.) The collection of copied parts is held by <a href="DraggingTool.html#copiedParts">copiedParts</a>. It too is a <a href="Map.html">Map</a> remembering the original locations of the parts. <a href="DraggingTool.html#copiedParts">copiedParts</a> will be null when this tool is moving (not copying) at the moment.</p> <p>Each Part&#39;s movement is limited by the <a href="Diagram.html#computeMove">Diagram.computeMove</a> method. By default it limits the <a href="Part.html#location">Part.location</a> to be within the bounds given by <a href="Part.html#minLocation">Part.minLocation</a> and <a href="Part.html#maxLocation">Part.maxLocation</a>. (Those default to minus Infinity to plus Infinity.) As a further convenience, the value of NaN in minLocation and maxLocation cause <a href="Diagram.html#computeMove">Diagram.computeMove</a> to use the part&#39;s current location. So, for example, an easy way to declare that the user may only drag a node horizontally is to just set:</p> <pre><code class="hljs js">$(go.Node, . . . { <span class="hljs-attr">minLocation</span>: <span class="hljs-keyword">new</span> go.Point(-<span class="hljs-literal">Infinity</span>, <span class="hljs-literal">NaN</span>), <span class="hljs-attr">maxLocation</span>: <span class="hljs-keyword">new</span> go.Point(<span class="hljs-literal">Infinity</span>, <span class="hljs-literal">NaN</span>) }, . . . )</code></pre> <p>If you set <a href="DraggingTool.html#isGridSnapEnabled">isGridSnapEnabled</a> to true, dragged or copied parts will be snapped to points on a grid. The snapping occurs continuously during a drag unless you set <a href="DraggingTool.html#isGridSnapRealtime">isGridSnapRealtime</a> to false. Normally the grid points come from the <a href="Diagram.html#grid">Diagram.grid</a>, even if that grid is not <a href="GraphObject.html#visible">GraphObject.visible</a>. However you can override those grid&#39;s properties for the snapping grid cell size and offset by setting the properties here: <a href="DraggingTool.html#gridSnapCellSize">gridSnapCellSize</a> and <a href="DraggingTool.html#gridSnapOrigin">gridSnapOrigin</a>. This computes the point to snap to for each dragged part. The resulting point is used as the new <a href="Part.html#location">Part.location</a>.</p> <p>For the most general control over where a part may be dragged, either set the <a href="Part.html#dragComputation">Part.dragComputation</a> property or override <a href="Diagram.html#computeMove">Diagram.computeMove</a>. For the common case of wanting to keep member nodes within the <a href="Group.html">Group</a> that they are members of, you can do something like:</p> <pre><code class="hljs js"> <span class="hljs-comment">// this is a Part.dragComputation function for limiting where a Node may be dragged</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">stayInGroup</span>(<span class="hljs-params">part, pt, gridpt</span>) </span>{ <span class="hljs-comment">// don't constrain top-level nodes</span> <span class="hljs-keyword">var</span> grp = part.containingGroup; <span class="hljs-keyword">if</span> (grp === <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> pt; <span class="hljs-comment">// try to stay within the background Shape of the Group</span> <span class="hljs-keyword">var</span> back = grp.resizeObject; <span class="hljs-keyword">if</span> (back === <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> pt; <span class="hljs-comment">// allow dragging a Node out of a Group if the Shift key is down</span> <span class="hljs-keyword">if</span> (part.diagram.lastInput.shift) <span class="hljs-keyword">return</span> pt; <span class="hljs-keyword">var</span> p1 = back.getDocumentPoint(go.Spot.TopLeft); <span class="hljs-keyword">var</span> p2 = back.getDocumentPoint(go.Spot.BottomRight); <span class="hljs-keyword">var</span> b = part.actualBounds; <span class="hljs-keyword">var</span> loc = part.location; <span class="hljs-comment">// find the padding inside the group's placeholder that is around the member parts</span> <span class="hljs-keyword">var</span> m = grp.placeholder.padding; <span class="hljs-comment">// now limit the location appropriately</span> <span class="hljs-keyword">var</span> x = <span class="hljs-built_in">Math</span>.max(p1.x + m.left, <span class="hljs-built_in">Math</span>.min(pt.x, p2.x - m.right - b.width - <span class="hljs-number">1</span>)) + (loc.x-b.x); <span class="hljs-keyword">var</span> y = <span class="hljs-built_in">Math</span>.max(p1.y + m.top, <span class="hljs-built_in">Math</span>.min(pt.y, p2.y - m.bottom - b.height - <span class="hljs-number">1</span>)) + (loc.y-b.y); <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> go.Point(x, y); }</code></pre> <p>Note that this expects there to be a &quot;SHAPE&quot; object within the Group&#39;s visual tree that delimits where the part may be dragged within the group. This also expects that <a href="Group.html#computesBoundsIncludingLinks">Group.computesBoundsIncludingLinks</a> is false. Then in your node template(s), just set:</p> <pre><code class="hljs js">$(go.Node, . . ., { <span class="hljs-attr">dragComputation</span>: stayInGroup }, . . . )</code></pre> <p>This tool does not utilize any <a href="Adornment.html">Adornment</a>s or tool handles. If the drag is successful, it raises the &quot;SelectionMoved&quot; or &quot;SelectionCopied&quot; <a href="DiagramEvent.html">DiagramEvent</a> and produces a &quot;Move&quot; or a &quot;Copy&quot; transaction.</p> <p>If you want to programmatically start a new user&#39;s dragging of a particular existing node, you can make sure that node is selected, set the <a href="DraggingTool.html#currentPart">currentPart</a> property, and then start and activate the tool.</p> <pre><code class="hljs js"> <span class="hljs-keyword">var</span> node = ...; myDiagram.select(node); <span class="hljs-comment">// in this case the only selected node</span> <span class="hljs-keyword">var</span> tool = myDiagram.toolManager.draggingTool; tool.currentPart = node; <span class="hljs-comment">// the DraggingTool will not call standardMouseSelect</span> myDiagram.currentTool = tool; <span class="hljs-comment">// starts the DraggingTool</span> tool.doActivate(); <span class="hljs-comment">// activates the DraggingTool</span></code></pre> </div> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section "> <h3>Constructors</h3> <ul class="tsd-index-list"> <li class="tsd-kind-constructor tsd-parent-kind-class"><a href="DraggingTool.html#constructor" class="tsd-kind-icon">constructor</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Properties</h3> <ul class="tsd-index-list"> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#copiedParts" class="tsd-kind-icon">copied<wbr>Parts</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#copiesEffectiveCollection" class="tsd-kind-icon">copies<wbr>Effective<wbr>Collection</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#currentPart" class="tsd-kind-icon">current<wbr>Part</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#delay" class="tsd-kind-icon">delay</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#dragOptions" class="tsd-kind-icon">drag<wbr>Options</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#draggedParts" class="tsd-kind-icon">dragged<wbr>Parts</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#dragsLink" class="tsd-kind-icon">drags<wbr>Link</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#dragsTree" class="tsd-kind-icon">drags<wbr>Tree</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#gridSnapCellSize" class="tsd-kind-icon">grid<wbr>Snap<wbr>Cell<wbr>Size</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#gridSnapCellSpot" class="tsd-kind-icon">grid<wbr>Snap<wbr>Cell<wbr>Spot</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#gridSnapOrigin" class="tsd-kind-icon">grid<wbr>Snap<wbr>Origin</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#isComplexRoutingRealtime" class="tsd-kind-icon">is<wbr>Complex<wbr>Routing<wbr>Realtime</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#isCopyEnabled" class="tsd-kind-icon">is<wbr>Copy<wbr>Enabled</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#isGridSnapEnabled" class="tsd-kind-icon">is<wbr>Grid<wbr>Snap<wbr>Enabled</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#isGridSnapRealtime" class="tsd-kind-icon">is<wbr>Grid<wbr>Snap<wbr>Realtime</a></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><a href="DraggingTool.html#startPoint" class="tsd-kind-icon">start<wbr>Point</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#canStart" class="tsd-kind-icon">can<wbr>Start</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#computeEffectiveCollection" class="tsd-kind-icon">compute<wbr>Effective<wbr>Collection</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#computeMove" class="tsd-kind-icon">compute<wbr>Move</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doActivate" class="tsd-kind-icon">do<wbr>Activate</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doCancel" class="tsd-kind-icon">do<wbr>Cancel</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doDeactivate" class="tsd-kind-icon">do<wbr>Deactivate</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doDragOver" class="tsd-kind-icon">do<wbr>Drag<wbr>Over</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doDropOnto" class="tsd-kind-icon">do<wbr>Drop<wbr>Onto</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doKeyDown" class="tsd-kind-icon">do<wbr>Key<wbr>Down</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doKeyUp" class="tsd-kind-icon">do<wbr>Key<wbr>Up</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doMouseMove" class="tsd-kind-icon">do<wbr>Mouse<wbr>Move</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#doMouseUp" class="tsd-kind-icon">do<wbr>Mouse<wbr>Up</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#findDraggablePart" class="tsd-kind-icon">find<wbr>Draggable<wbr>Part</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#mayCopy" class="tsd-kind-icon">may<wbr>Copy</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#mayMove" class="tsd-kind-icon">may<wbr>Move</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#moveParts" class="tsd-kind-icon">move<wbr>Parts</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="DraggingTool.html#standardMouseSelect" class="tsd-kind-icon">standard<wbr>Mouse<wbr>Select</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Constructors</h2> <section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"> <a name="constructor" class="tsd-anchor"></a> <h3> constructor </h3> <ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">new <wbr>Dragging<wbr>Tool<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="DraggingTool.html" class="tsd-signature-type">DraggingTool</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>You do not normally need to create an instance of this tool because one already exists as the <a href="ToolManager.html#draggingTool">ToolManager.draggingTool</a>, which you can modify.</p> <p>The <a href="Tool.html#name">Tool.name</a> of this tool is &quot;Dragging&quot;.</p> </div> <h4 class="tsd-returns-title">Returns <a href="DraggingTool.html" class="tsd-signature-type">DraggingTool</a></h4> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Properties</h2> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="copiedParts" class="tsd-anchor"></a> <h3> copied<wbr>Parts <span class="tsd-signature-symbol">: </span><a href="Map.html" class="tsd-signature-type">Map</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">, </span><a href="DraggingInfo.html" class="tsd-signature-type">DraggingInfo</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets the collection of <a href="Part.html">Part</a>s that this tool has copied. The value is a <a href="Map.html">Map</a> mapping <a href="Part.html">Part</a>s to DraggingInfo Objects that have a &quot;point&quot; property remembering the original location of that Part. The value is null when moving instead of copying.</p> <p><a href="DraggingTool.html#draggedParts">draggedParts</a> provides the map of Parts that are being moved and from which this collection was copied.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="copiesEffectiveCollection" class="tsd-anchor"></a> <h3> copies<wbr>Effective<wbr>Collection <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether for a copying operation the extended selection is copied or only the selected parts. The default value is true. Setting this property does not raise any events.</p> <p>The <a href="CommandHandler.html#copiesConnectedLinks">CommandHandler.copiesConnectedLinks</a> property serves a similar role for the <a href="CommandHandler.html#copySelection">CommandHandler.copySelection</a> command, when the user types control-C to copy the currently selected parts.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="currentPart" class="tsd-anchor"></a> <h3> current<wbr>Part <span class="tsd-signature-symbol">: </span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets the <a href="Part.html">Part</a> found at the mouse point. This is normally set by a call to <a href="DraggingTool.html#standardMouseSelect">standardMouseSelect</a>.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="delay" class="tsd-anchor"></a> <h3> delay <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>On touch gestures only, this property gets or sets the time in milliseconds for which the mouse must be stationary before this tool can be started. The default value is 100 milliseconds. Setting this property does not raise any events.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="dragOptions" class="tsd-anchor"></a> <h3> drag<wbr>Options <span class="tsd-signature-symbol">: </span><a href="DraggingOptions.html" class="tsd-signature-type">DraggingOptions</a> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets the <a href="DraggingTool.html">DraggingTool</a>&#39;s <a href="DraggingOptions.html">DraggingOptions</a> instance, which controls several dragging properties.</p> <p>Several DraggingTool properties are just convenience properties:</p> <ul> <li><a href="DraggingTool.html#isGridSnapEnabled">isGridSnapEnabled</a></li> <li><a href="DraggingTool.html#isGridSnapRealtime">isGridSnapRealtime</a></li> <li><a href="DraggingTool.html#gridSnapCellSize">gridSnapCellSize</a></li> <li><a href="DraggingTool.html#gridSnapCellSpot">gridSnapCellSpot</a></li> <li><a href="DraggingTool.html#gridSnapOrigin">gridSnapOrigin</a></li> <li><a href="DraggingTool.html#dragsLink">dragsLink</a></li> <li><a href="DraggingTool.html#dragsTree">dragsTree</a></li> </ul> <p>Setting any of these properties really sets the corresponding dragOptions property.</p> <p>Setting this property does not raise any events.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>2.0</p> </dd> </dl> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="draggedParts" class="tsd-anchor"></a> <h3> dragged<wbr>Parts <span class="tsd-signature-symbol">: </span><a href="Map.html" class="tsd-signature-type">Map</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">, </span><a href="DraggingInfo.html" class="tsd-signature-type">DraggingInfo</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets the collection of <a href="Part.html">Part</a>s being moved. The value is a <a href="Map.html">Map</a> mapping <a href="Part.html">Part</a>s to DraggingInfo Objects that have a &quot;point&quot; property remembering the original location of that Part.</p> <p><a href="DraggingTool.html#copiedParts">copiedParts</a> provides the map of Parts that have been copied during a copying operation, if any.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="dragsLink" class="tsd-anchor"></a> <h3> drags<wbr>Link <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether the user can drag a single <a href="Link.html">Link</a>, disconnecting it from its connected nodes and possibly connecting it to valid ports when the link is dropped. The default value is false. Setting this property does not raise any events.</p> <p>In order to avoid too many cases of having both ends of a dragged Link connect to the same node (if allowed), it is commonplace to decrease the <a href="LinkingBaseTool.html#portGravity">LinkingBaseTool.portGravity</a> to a smaller value such as 10 or 20.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.3</p> </dd> </dl> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="dragsTree" class="tsd-anchor"></a> <h3> drags<wbr>Tree <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether moving or copying a node also includes all of the node&#39;s tree children and their descendants, along with the links to those additional nodes. The default value is false. Setting this property does not raise any events.</p> <p>The <a href="CommandHandler.html#copiesTree">CommandHandler.copiesTree</a> property serves a similar role for the <a href="CommandHandler.html#copySelection">CommandHandler.copySelection</a> command, when the user types control-C to copy the currently selected parts.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="gridSnapCellSize" class="tsd-anchor"></a> <h3> grid<wbr>Snap<wbr>Cell<wbr>Size <span class="tsd-signature-symbol">: </span><a href="Size.html" class="tsd-signature-type">Size</a> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets the size of the grid cell used when snapping during a drag if the value of <a href="DraggingTool.html#isGridSnapEnabled">isGridSnapEnabled</a> is true. By default this property is the Size(NaN, NaN), which causes this tool to use the <a href="Panel.html#gridCellSize">Panel.gridCellSize</a> value of the <a href="Diagram.html#grid">Diagram.grid</a>. Setting this property does not raise any events.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="gridSnapCellSpot" class="tsd-anchor"></a> <h3> grid<wbr>Snap<wbr>Cell<wbr>Spot <span class="tsd-signature-symbol">: </span><a href="Spot.html" class="tsd-signature-type">Spot</a> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets the <a href="Spot.html">Spot</a> that specifies what point in the grid cell dragged parts snap to, if the value of <a href="DraggingTool.html#isGridSnapEnabled">isGridSnapEnabled</a> is true. By default this property is <a href="Spot.html#static-TopLeft">Spot.TopLeft</a>: node locations will snap exactly to the grid point. Setting this property does not raise any events.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="gridSnapOrigin" class="tsd-anchor"></a> <h3> grid<wbr>Snap<wbr>Origin <span class="tsd-signature-symbol">: </span><a href="Point.html" class="tsd-signature-type">Point</a> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets the snapping grid&#39;s origin point, in document coordinates, if the value of <a href="DraggingTool.html#isGridSnapEnabled">isGridSnapEnabled</a> is true. By default this property is the Point(NaN, NaN), which causes this tool to use the <a href="Panel.html#gridOrigin">Panel.gridOrigin</a> value from the <a href="Diagram.html#grid">Diagram.grid</a>. Setting this property does not raise any events.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="isComplexRoutingRealtime" class="tsd-anchor"></a> <h3> is<wbr>Complex<wbr>Routing<wbr>Realtime <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether link routing takes some short-cuts during dragging. When false Links whose routing is AvoidsNodes are not routed to avoid Nodes, in order to improve dragging performance. The default value is true.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.4</p> </dd> </dl> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="isCopyEnabled" class="tsd-anchor"></a> <h3> is<wbr>Copy<wbr>Enabled <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether for any internal copying operation is permitted by control-drag-and-drop. This property affects the behavior of <a href="DraggingTool.html#mayCopy">mayCopy</a>, but does not affect whether copied objects may be dropped into this diagram from a different diagram.</p> <p>The default value is true. Setting this property does not raise any events.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.4</p> </dd> </dl> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="isGridSnapEnabled" class="tsd-anchor"></a> <h3> is<wbr>Grid<wbr>Snap<wbr>Enabled <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether the <a href="DraggingTool.html">DraggingTool</a> snaps objects to grid points. Whether the snapping movement of the dragged parts occurs during the drag or only upon a drop is determined by the value of <a href="DraggingTool.html#isGridSnapRealtime">isGridSnapRealtime</a>.</p> <p>This property does not affect dragging disconnected links, but those links to respect the <a href="Part.html#dragComputation">Part.dragComputation</a>, which can be used to snap them.</p> <p>By default this property is false. Setting this property does not raise any events.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="isGridSnapRealtime" class="tsd-anchor"></a> <h3> is<wbr>Grid<wbr>Snap<wbr>Realtime <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets whether the <a href="DraggingTool.html">DraggingTool</a> snaps objects to grid points during the drag. This property is ignored unless <a href="DraggingTool.html#isGridSnapEnabled">isGridSnapEnabled</a> is true. By default this property is true; when false parts are only snapped to grid locations upon the drop (i.e. mouse-up). Setting this property does not raise any events.</p> <p>This property is a convenience getter/setter, and sets a value on <a href="DraggingTool.html#dragOptions">dragOptions</a>.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.1</p> </dd> </dl> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class"> <a name="startPoint" class="tsd-anchor"></a> <h3> start<wbr>Point <span class="tsd-signature-symbol">: </span><a href="Point.html" class="tsd-signature-type">Point</a> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets or sets the mouse point from which parts start to move. The value is a Point in document coordinates. This property is normally set to the diagram&#39;s mouse-down point in <a href="DraggingTool.html#doActivate">doActivate</a>, but may be set to a different point if parts are being copied from a different control. Setting this property does not raise any events.</p> </div> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="canStart" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagVirtual">Virtual</span> <span class="tsd-flag ts-flagOverride">Override</span> can<wbr>Start </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">can<wbr>Start<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>This tool can run if the diagram allows selection and moves/copies/dragging-out, if the mouse has moved far enough away to be a drag and not a click, and if <a href="DraggingTool.html#findDraggablePart">findDraggablePart</a> has found a selectable part at the mouse-down point.</p> <p>This method may be overridden. Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="computeEffectiveCollection" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagVirtual">Virtual</span> compute<wbr>Effective<wbr>Collection </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">compute<wbr>Effective<wbr>Collection<span class="tsd-signature-symbol">(</span>parts<span class="tsd-signature-symbol">: </span><a href="Iterable.html" class="tsd-signature-type">Iterable</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">&gt;</span>, options<span class="tsd-signature-symbol">: </span><a href="DraggingOptions.html" class="tsd-signature-type">DraggingOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Map.html" class="tsd-signature-type">Map</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">, </span><a href="DraggingInfo.html" class="tsd-signature-type">DraggingInfo</a><span class="tsd-signature-symbol">&gt;</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>This just calls <a href="CommandHandler.html#computeEffectiveCollection">CommandHandler.computeEffectiveCollection</a>. The implementation of this method was moved to CommandHandler for 2.0.</p> <p>This method may be overridden. Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>parts: <a href="Iterable.html" class="tsd-signature-type">Iterable</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">&gt;</span></h5> <div class="tsd-comment tsd-typography"> <p>A <a href="Set.html">Set</a> or <a href="List.html">List</a> of <a href="Part.html">Part</a>s.</p> </div> </li> <li> <h5>options: <a href="DraggingOptions.html" class="tsd-signature-type">DraggingOptions</a></h5> <div class="tsd-comment tsd-typography"> <p>Potential options for the collection computation</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="Map.html" class="tsd-signature-type">Map</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">, </span><a href="DraggingInfo.html" class="tsd-signature-type">DraggingInfo</a><span class="tsd-signature-symbol">&gt;</span></h4> <p>a Map mapping <a href="Part.html">Part</a>s to DraggingInfo Objects that have a &quot;point&quot; property remembering the original location of that Part.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="computeMove" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagVirtual">Virtual</span> compute<wbr>Move </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">compute<wbr>Move<span class="tsd-signature-symbol">(</span>n<span class="tsd-signature-symbol">: </span><a href="Part.html" class="tsd-signature-type">Part</a>, newloc<span class="tsd-signature-symbol">: </span><a href="Point.html" class="tsd-signature-type">Point</a>, draggedparts<span class="tsd-signature-symbol">?: </span><a href="Map.html" class="tsd-signature-type">Map</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">, </span><a href="DraggingInfo.html" class="tsd-signature-type">DraggingInfo</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span>, result<span class="tsd-signature-symbol">?: </span><a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Point.html" class="tsd-signature-type">Point</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>This method computes the new location for a <a href="Node.html">Node</a> or simple <a href="Part.html">Part</a>, given a new desired location and an optional Map of dragged parts, taking any grid-snapping into consideration, any <a href="Part.html#dragComputation">Part.dragComputation</a> function, and any <a href="Part.html#minLocation">Part.minLocation</a> and <a href="Part.html#maxLocation">Part.maxLocation</a>.</p> <p>As of 2.0, this just calls <a href="Diagram.html#computeMove">Diagram.computeMove</a> and remains for compatibility.</p> <p>This method may be overridden, but should usually be overridden on Diagram. Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.1</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>n: <a href="Part.html" class="tsd-signature-type">Part</a></h5> <div class="tsd-comment tsd-typography"> <p>the Node or simple Part that is being moved</p> </div> </li> <li> <h5>newloc: <a href="Point.html" class="tsd-signature-type">Point</a></h5> <div class="tsd-comment tsd-typography"> <p>the proposed new location</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> draggedparts: <a href="Map.html" class="tsd-signature-type">Map</a><span class="tsd-signature-symbol">&lt;</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">, </span><a href="DraggingInfo.html" class="tsd-signature-type">DraggingInfo</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></h5> <div class="tsd-comment tsd-typography"> <p>an optional Map mapping <a href="Part.html">Part</a>s to DraggingInfo Objects that have a &quot;point&quot; property remembering the original location of that Part.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> result: <a href="Point.html" class="tsd-signature-type">Point</a></h5> <div class="tsd-comment tsd-typography"> <p>an optional Point that is modified and returned</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="Point.html" class="tsd-signature-type">Point</a></h4> <p>the possibly grid-snapped computed Point that is within the minimum and maximum permitted locations</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="doActivate" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagOverride">Override</span> do<wbr>Activate </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">do<wbr>Activate<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Start the dragging operation. This calls <a href="DraggingTool.html#computeEffectiveCollection">computeEffectiveCollection</a> and saves the result as <a href="DraggingTool.html#draggedParts">draggedParts</a>.</p> <p>This starts a &quot;Drag&quot; transaction. Depending on what happens, the transaction may be finished as a &quot;Move&quot; or a &quot;Copy&quot; transaction, or it may be rolled-back if the tool is cancelled.</p> <p>Normally when this method is called the value of <a href="DraggingTool.html#currentPart">currentPart</a> will be null, in which case this will call <a href="Tool.html#standardMouseSelect">Tool.standardMouseSelect</a> which will set <a href="DraggingTool.html#currentPart">currentPart</a>. But if when this method is called the value of <a href="DraggingTool.html#currentPart">currentPart</a> has already been set because the programmer wants the user to start dragging that Part, then this method will not need to call <a href="Tool.html#standardMouseSelect">Tool.standardMouseSelect</a> because the Part(s) to be selected and dragged have already been determined by the caller.</p> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="doCancel" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagOverride">Override</span> do<wbr>Cancel </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">do<wbr>Cancel<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Abort any dragging operation.</p> </div> <h4 class="tsd-returns-title">Return