简体   繁体   中英

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 :)

So I found the solution :

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM