Due to @Kangax comment which solved most of the problem, I found the following solution to delete the currently selected objects from the canvas.
var deleteSelectedObject = document.getElementById('delete-item');
deleteSelectedObject.onclick = function()
{
if(canvas.getActiveGroup()){
canvas.getActiveGroup().forEachObject(function(o){ canvas.remove(o) });
canvas.discardActiveGroup().renderAll();
} else {
canvas.remove(canvas.getActiveObject());
}
};
The function checks whether a group is selected. If a group is selected every object of the group gets removed.
If no group is selected the function tries to remove a selected object. If nothing is selected, the canvas is not changed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…