How to disable the polygon and poly line until the tool has been clicked?


Just wondering How to disable the polygon and poly line in the PolygonDrawing until the tool has been clicked?
In other words I only want to draw a polygon or poly line until the tool button is clicked,


I do not understand your question. What tool button are you talking about? The extensions/PolygonDrawingTool.js tool does not show any temporary buttons in the diagram. I suppose the Parts in your app could show buttons permanently. Or they could have Adornments which included some buttons. But I wouldn’t know about that.

Hello Walter, Sorry I have not explained this very well. I am referring to the extensions/PolygonDrawingTool.js yes. What i’m trying to explain is that when we load the PolygonDrawing.html document you can draw the Polygon on the canvas by default, What i would like is for my app not to draw it on the canvas by default. I think it is this part in the init function -> // create polygon drawing tool for myDiagram, defined in PolygonDrawingTool.js
var tool = new PolygonDrawingTool();
// provide the default JavaScript object for a new polygon in the model
tool.archetypePartData =
{ fill: “transparent”, stroke: “black”, strokeWidth: 3 };
tool.isPolygon = true; // for a polyline drawing tool set this property to false
// install as first mouse-down-tool
myDiagram.toolManager.mouseDownTools.insertAt(0, tool);

Whenever i try to disable the Polygon and Polyline it breaks and i cannot even draw the Polygon or polgyline when i clicked the buttons to do so. What i desire is to have them tools turned off until i click on the tool buttons.

Hope i have explained more clearly,


That is purely a design of that app, not in the definition of the tool. See how the HTML buttons change the state of the diagram, including its tools.

Hello Walter, I have checked, tried countless time with no luck. I have purchased gojs if there is any additional guidance I can have on this matter?.

Thank you

Hi. As far as we can tell, your company has not made any purchase. But that doesn’t affect our support during your evaluation period.

If you look at the implementation of that sample app, it adds an instance of the PolygonDrawingTool to the start of the ToolManager’s mouseDownTools list. So any mouse down event will cause the ToolManager to ask the PolygonDrawingTool whether or not it canStart(). That is returning true, so the PolygonDrawingTool is started by making it the Diagram.currentTool.

If you look at the implementation of the “Select” HTML button, it sets the PolygonDrawingTool’s isEnabled property to false in order to disable it.

So if you don’t want a tool to be able to run initially, set its Tool.isEnabled property to false.