I have a method that selects the objects on the canvas by clicking a button. But, how to validate that when I select it? It skips the group (which doesn't select the group) and only the individual objects;
here I generate a group of figures
const group = new fabric.Group([
new fabric.Rect({ width: 100, height: 100, fill: 'red' }),
new fabric.Rect({ width: 100, height: 100, fill: 'yellow', left: 100 }),
new fabric.Rect({ width: 100, height: 100, fill: 'blue', top: 100 }),
new fabric.Rect({
width: 100,
height: 100,
fill: 'green',
left: 100,
top: 100
})
])
this.canvas.add(group)
I create an individual figure
let rect1 = new fabric.Rect( {
width: 100,
height: 100,
fill: 'transparent',
stroke: 'blue',
left: 140
});
this.canvas.add(rect1)
I create another individual figure
let rect2 = new fabric.Rect( {
width: 100,
height: 100,
fill: 'transparent',
stroke: 'blue',
left: 240
});
this.canvas.add(rect2)
Here my select method, but I select both the group and the individual objects. How can I validate so that it only selects the objects and not the group?
multiseleccion(){
this.canvas?.discardActiveObject();
this.seleccionar = new fabric.ActiveSelection(this.canvas?.getObjects(), {
canvas: this.canvas
});
this.canvas?.setActiveObject(this.seleccionar);
this.canvas?.requestRenderAll();