PartCreated ChangedSelection firing order

I use the PartCreated event to add dynamic data to a Node’s model. I also have a ChangedSelection event which uses this dynamic data to notify our app which nodes are selected to update our property panel. I’m running into a problem where a new node is causing the ChangedSelection event to fire before the PartCreated, and the ChangedSelection event doesn’t have the data it needs that PartCreated populates.

Is there a way to tell the diagram which order to fire these events? If not any other ideas? I need both events to fire - just in the order of PartCreated -> ChangedSelection.


Instead of implementing a “PartCreated” DiagramEvent listener, override myDiagram.toolManager.clickCreatingTool.insertPart to first modify the ClickCreatingTool.archetypeNodeData and then call the base method for the usual behavior.

That works and actually gives me more control. Did the same for LinkingTool.insertLink and couldn’t figure out why it wasn’t working. Finally realized it returns a value Censored

link =, fromnode, fromport, tonode, toport);

I better pay more attention to the API when overriding functions…

Actually, both methods are defined to return a value, but I guess you got away with it for insertPart because the ClickCreatingTool calling insertPart didn’t happen to depend on the return value.

Another difference between the two methods is that insertPart needs to conduct its own transaction and raise the “PartCreated” DiagramEvent, whereas insertLink is called during a transaction that is occurring while the tool is active and the caller needs to decide about raising any DiagramEvent.

The “flexibility” of JavaScript is helpful sometimes but hinders detecting bugs that would be caught at compile-time in other languages.