Reputation: 3913
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/
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());
}
Upvotes: 0
Views: 2292
Reputation: 10153
getActiveGroup
seems to be buggy. getActiveObject
returns the active group though, so you can go with that. 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:
function CurvedText( canvas, options ){
...
this.group.curvedText = this;
}
and then
var act = canvas.getActiveObject();
act.curvedText.setText($(this).val());
like I did here.
Upvotes: 1