[英]get Active Elements of canvas not working
how can i get active Object or Active Group in below Example ?? 在下面的示例中,如何获取活动对象或活动组? i am using this . 我正在使用这个。 in this fiddle i am trying to create curved text whenever text-box value is changed . 在这个小提琴中,我试图在更改文本框值时创建弯曲的文本。 i need to get active object of canvas to apply size and all changes but active group or element not working . 我需要获取画布的活动对象以应用大小和所有更改,但活动组或元素不起作用。 how can i do this ? 我怎样才能做到这一点 ?
Fiddle :: http://jsfiddle.net/NHs8t/8/ 小提琴:: http://jsfiddle.net/NHs8t/8/
Below snippts of fiffle:: 在片段的下面:
var act = canvas.getActiveGroup();
var obj = canvas.getActiveObject();
if(!obj)
{
console.log('object not Selected');
}else
{
console.log('Object selected');
}
if (!canvas.getActiveGroup())
{
console.log('if part executed--object not selected');
curvedText[cur] = new CurvedText(canvas, {});
curvedText[cur].center();
curvedText[cur].setText($(this).val());
cur++;
} else {
console.log('Else part executed-object selected');
act.setText($(this).val());
}
getActiveGroup
seems to be buggy. getActiveGroup
似乎有问题。 getActiveObject
returns the active group though, so you can go with that. 尽管getActiveObject
返回活动组,所以您可以继续使用。 Problem is you won't have access to your setText
method through the group, so you'll have to keep a reference to the CurvedText
instance in the group: 问题是您将无法通过该组访问setText
方法,因此您必须在该组中保留对CurvedText
实例的引用:
function CurvedText( canvas, options ){
...
this.group.curvedText = this;
}
and then 接着
var act = canvas.getActiveObject();
act.curvedText.setText($(this).val());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.