faniva
faniva

Reputation: 320

How can I "highlight" object programatically, without actually "selecting" the object

So I have this situation:

I have an object in the canvas which is deselected. I would like to show the object's controls (handles and borders) to give the appearance of it being "highlighted" but not actually selecting the object (meaning not doing canvas.setActiveObject(obj) )

Just want to be able to show the object's controls, that's it.

What I tried was doing this :

fabric.Object.prototype.highlight = function(){      
        this.hasControls = true;
        this.dirty = true;
        this.canvas.renderAll();
    };

but no luck. Thanks to everyone in advance :)

Upvotes: 2

Views: 181

Answers (1)

faniva
faniva

Reputation: 320

So I found the solution :

fabric.Object.prototype.highlight = function(){
   this.canvas._setActiveObject(this);
};

and then just use like: obj.highlight();

Upvotes: 2

Related Questions