I have reedited restored rectangle and other shapes in this way
var Rectanglenodes = stage.find('Rect');
for (var i = 0; i < Rectanglenodes.length; i++) {
var rect = Rectanglenodes[i];
rect.on("mousedown", function (e) {
var node = e.targetNode;
selectednode = e.targetNode;
selectednodecount = 1;
if (drawingObject == "delete") {
var parentnode = node.parent;
parentnode.destroy();
stage.draw();
}
else if (drawingObject == "clearAll") {
layerText.destroy();
layerLine.destroy();
layerCircle.destroy();
layerrect.destroy();
drawingObject = "";
}
else if (drawingObject == "select") {
select(node);
var children = node.parent.children;
var group = node.parent;
for (i = 1; i < children.length; i++) {
var str = children[i].getId();
var n = str.length;
var anchorId = str.substring(0, (n - 1));
if (anchorId.toLowerCase().indexOf("rect") >= 0) {
children[i].on('dragmove', function () {
update(this, e);
console.log(this);
layerrect.draw();
});
children[i].on('mousedown touchstart', function () {
group.setDraggable(false);
this.moveToTop();
});
children[i].on('dragend', function () {
group.setDraggable(true);
layerrect.draw();
});
children[i].on('mouseover', function () {
var layer = this.getLayer();
document.body.style.cursor = 'pointer';
this.setStrokeWidth(4);
layerrect.draw();
});
children[i].on('mouseout', function () {
var layer = this.getLayer();
document.body.style.cursor = 'default';
this.strokeWidth(2);
layerrect.draw();
});
}
}
}
});
}