简体   繁体   English

如何以编程方式“突出显示”对象,而不实际“选择”对象

[英]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) ) 我想显示该对象的控件(句柄和边框)以使其外观为“突出显示”,但实际上并未选择该对象(这意味着不做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(); 然后就像这样使用:obj.highlight();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript-如何迭代实际上是地图的对象? - JavaScript - How can I iterate object that is actually a map? 如何突出显示 DOM Range 对象的文本? - How can I highlight the text of the DOM Range object? 如何从对象中选择数据时使用函数参数? - How can I use a function argument in selecting data from an object? 如何使用 object 在 canvas 上绘图并在不绘图的情况下移动 object? - How can i draw on canvas with an object and move the object without drawing? 如何在 razor 页面中以编程方式添加的行中基于 td 值简要突出显示表行 - How can I briefly highlight a table row based on a td value, in a programatically added row in a razor page JSON.parse() 如何能够在没有实际在 JSON 端点中定义对象属性的情况下解析为 JS 对象? - How is that JSON.parse() is able to parse to JS Object without actually having the Object Propery defined in the JSON endpoint? 如何在不使用插件的情况下以编程方式记录浏览器操作 - How can I programatically record browser actions without using a plugin 为了选择或聚焦对象,如何使右键单击的行为与单击鼠标左键的行为相同 - How can I make a right-click behave as a left-click for the purpose of selecting or focusing an object 如何在不指定属性的情况下显示对象内容? - How can I display object content without specifying the attributes? 如何在不使用框架的情况下编写面向对象的Javascript? - How can I write object oriented Javascript without using a framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM