I want to make all object in canvas unselectable. I've found selectable method but i didn't find the way to implement it to all objects.
I was looking for an unmovable and uneditable Fabric Text and I finally found a solution combining several SO, hope I can save someone some time.
Using "selectable": false wasn't enough in my case : the text was still editable and the cursor was still the "movable cursor" (even if the object wasn't selectable).
I had to add "evented": false. Here is an example:
this.canvas.add(new fabric.Text("Hello world !", {
"selectable": false,
"evented": false
}));
You can play with different control options here : http://fabricjs.com/controls-customization
You can make all the elements un-selectable using below code
canvas.deactivateAll();
canvas.renderAll();
canvas.forEachObject(function(object){
object.selectable = false;
});
There is a way like this in option -
selectable: false
or
object.set({selectable:false})
or
object.selectable = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With