How to make objects in canvas unselectable?

Yevgen picture Yevgen · Jul 23, 2012 · Viewed 12.7k times · Source

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.

Answer

Emerica picture Emerica · Apr 9, 2019

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