Adding a tool to the ToolManager

Could you please explain the following function call:

myDiagram.toolManager.mouseMoveTools.insertAt(2, new DragZoomingTool());

What is meaning of insertAt and its first argument (“2”) here.

Please read the documentation:

Inserting a new tool at index 2 of that List of mouse-move tools means that it takes precedence before the DragSelectingTool when the ToolManager asks the Tools in that list whether they Tool.canStart.

Thanks @walter for the info.

How can i enable/disable DragZoomingTool programmatically?

If you read about Tools:

https://gojs.net/latest/intro/tools.html

you will read about this property:

I have tried with “isEnables” property, but it is not working for GoJS Extension tool like DragZoomingTool

isEnable is working for panningTool and other tools managed by toolManager as follows:

myDiagram.toolManager.panningTool.isEnabled = true;

But, not for mouseMoveTools managed by toolManager.

myDiagram.toolManager.mouseMoveTools.DragZoomingTool.isEnable = true/false

not working.

Could you please suggest, how to achieve this for DragZoomingTool.

Thanks.

All of the predefined Tools in the ToolManager are Tool.isEnabled initially.

You can disable a tool when initializing a Diagram with:

    "xyzTool.isEnabled": false,

Or disable it at any time by:

  myDiagram.toolManager.xyzTool.isEnabled = false;

Sorry, but i have tried following 3 ways for Enabling/Disabling DragZoomingTool:

  1. myDiagram.toolManager.DragZoomingTool.isEnable = true/false
  2. myDiagram.toolManager.mouseMoveTools.isEnable = true/false
  3. myDiagram.toolManager.mouseMoveTools.DragZoomingTool.isEnable = true/false

but, none of them is working for me.

DragZoomingTool is not a predefined tool in the ToolManager, so there can be no property for it on the ToolManager class.

Instead, you need to find the tool before you can set a property on it. Call ToolManager | GoJS API.

  myDiagram.toolManager.findTool("DragZoomingTool").isEnabled = false;

Please be careful with spelling.

Thanks @walter. It works for me.

Just a correction:

myDiagram.toolManager.findTool(“DragZooming”).isEnabled = false;