const pointtoreduce = 42;
const mx = event.clientX - pointtoreduce;
const my = event.clientY - pointtoreduce;
const point = this.myDiagram.transformViewToDoc(new go.Point(mx, my));
const droptoPart = this.myDiagram.findPartAt(point, false);
console.log('droptoPart', droptoPart);
const node = this.getNodeFromGroupButton(this.toolbarService.selectedGroup);
if (undefined !== node) {
delete node['__gohashid'];
if (droptoPart instanceof go.Group) {
node['group'] = droptoPart.data.key;
}
this.myDiagram.startTransaction('new node');
if (node['category'] === 'Pool') {
this.createPool(node, point);
} else if (node['category'] === 'subprocess') {
this.createSubprocess(node, point);
} else {
node['key'] = this.getKey(node['key']);
node['loc'] = `${point.x}` + `${' '}` + `${point.y}`;
this.myDiagram.model.addNodeData(node);
console.log('this.myDiagram.findNodeForKey', node['key']);
// console.log('this.myDiagram.model.addNodeData(node)', this.myDiagram.model.addNodeData(node));
this.myDiagram.findNodeForKey(node['key']).isSelected = true;
//console.log('this.myDiagram.findNodeForKey', node['key']);
this.myDiagram.select(this.myDiagram.findNodeForKey(node['key']));
}
this.myDiagram.commitTransaction('new node');
this.createprops(this.myDiagram.findNodeForKey(node['key']));
}
this.myDiagram.commandHandler.diagram.doFocus();
}, false);
this.myDiagram.addDiagramListener('SelectionCopied', () => {
this.relayoutDiagramEx(this._self);
});
this.createDummyNode();
}```
please look into the code and give me a solution.The code of "getNodeFromGroupButton" is given below:
```private getNodeFromGroupButton(selectedGroup: string): object {
let node;
switch (selectedGroup) {
case 'start':
node = this.toolbarService.startGroupNode.data;
console.log('node',node);
console.log('node stringfy',JSON.stringify(node));
break;
case 'intermediate':
node = this.toolbarService.interMediateGroupNode.data;
break;
case 'end':
node = this.toolbarService.endGroupNode.data;
break;
case 'task':
node = this.toolbarService.taskGroupNode.data;
break;
case 'subprocess':
node = this.toolbarService.subProcessGroupNode.data;
break;
case 'gateway':
node = this.toolbarService.subProcessGroupNode.data;
break;
case 'artifacts':
node = this.toolbarService.artifactGroupNode.data;
break;
case 'dataobject':
node = this.toolbarService.dataGroupNode.data;
break;
default:
break;
}
return node;
}```
I was trying to put the shape from the flyout…1st time it was sucessfull…2nd time when I try it throws an error “ERROR TypeError: Cannot set property ‘isSelected’ of null”…Pasting the code below
Don’t touch the __gohashid property!