How can I turn off DragCreating Tool after it finishes Drawing

I am struggling with turning off the DragCreatingTool, I want to disable tool after it finishes drawing and re activate it with button instead of
< label>< input id=“ToolEnabled” type=“checkbox” checked=“checked” onclick=“toolEnabled()” />DragCreatingTool enabled
from Drag Creating Tool

So you want to disable it automatically after each operation? And you have some other code that will either enable it or explicitly run the tool when you want?

For the built-in tools, it would be easiest to implement a DiagramEvent listener for that tool’s operation that just disabled the tool, just as the HTML checkbox listener does in that sample.

However, since the DragCreatingTool isn’t a built-in tool, there’s no DiagramEvent listener for its operation. So the easiest thing to do is to override DragCreatingTool.insertPart to call the super method and then disable the tool.

Oh, that sample does such an override already, although for a different purpose.

Yes, after each operations i want it disabled.

I am enabling it with a function,

var drawRectangle = function () {
var drawRectangleToolEnabled =
var tool = _DIAGRAM.toolManager.findTool(“DragCreating”);
tool.archetypeNodeData = {
fill: “transparent”,
stroke: “black”,
strokeWidth: 2,
figure: “Rectangle”,
category: “DragRectangle”,
tool.isEnabled = drawRectangleToolEnabled;

With the check box example I was handling the tool disable with the following code

var handleDiagramUpdates = function (e) {
var button = document.getElementById(“SaveDiagram”);
if (button) button.disabled = !e.diagram.isModified;
console.log("modify: " + e.diagram.isModified);
var dragtool1 = _DIAGRAM.toolManager.findTool(“DragCreating”);
if (e.diagram.currentTool == dragtool1 && e.diagram.isModified == true) {
dragtool1.isEnabled = false;
document.getElementById(“dragRectangle”).checked = false;

but however it was not working as expected always.

If you step through your code you will see that drawRectangleToolEnabled in your code is the click event handler of that rectangleToolBtn element. I rather doubt that is what you want to set Tool.isEnabled to.

It also seems unlikely that you want to depend on Diagram.isModified to decide whether to enable the tool. But I’m not sure what you really want.