Hi,
If you only need to change the type of diagram elements being drawn to a custom type, it's enough to set Behavior=Custom and CustomNodeType=typeof(...) as shown in IconNodes sample project.
If you need to decide the type of items at runtime, there's no documented method of doing it, but you could create a custom JS BehaviorBase -derived class and assign its instance to Diagram.currentBehavior field. The default behavior that draws either nodes or links is implemented like this -
startDraw: function (point)
{
var ist;
var handle = null;
var originNode = this.diagram.getNodeAt(point, true, true);
if (originNode != null && originNode.acceptLinks(true))
{
var link = this.createLink(originNode, point);
handle = { item: link, index: link.points.length - 1 };
ist = new mdiag.InteractionState(link, mdiag.Action.Create, handle, point);
this.diagram.addItem(link);
}
else
{
var w = this.diagram.getAlignToGrid() ? this.diagram.getGridSizeX() : 1;
var h = this.diagram.getAlignToGrid() ? this.diagram.getGridSizeY() : 1;
var node = this.createNode();
var alignedPoint = this.diagram.alignResize(node, point, mdiag.AdjustmentHandles.ResizeTopLeft);
node.setBounds(new MindFusion.Drawing.Rect(alignedPoint.x, alignedPoint.y, w, h));
handle = { item: node, index: 2 };
ist = new mdiag.InteractionState(node, mdiag.Action.Create, handle, point);
this.diagram.addItem(node);
}
return ist;
},
Regards,
Slavcho
Mindfusion