Using latest Fabric.js, I have the code:
var imageAdded = new Image();
imageAdded.onload = function (img) {
var imgAdded = new fabric.Image(imageAdded, {
clipName: picID,
clipTo: function (ctx) {
return _.bind(clipByName, imgAdded)(ctx)
}
});
canvas.add(imgAdded);
imgAdded.on("object:selected", function (e) { // It doesn't pass this function
alert(e.target.clipName + " is selected");
e.target.clipTo = null;
canvas.renderAll();
});
};
- I want to alert when I select an object but no alert is showed because the function where I made a ment in the code doesn't work.
- I tried this link but still can't make it possible.
I appreciate every suggestion. Thank you!
Using latest Fabric.js, I have the code:
var imageAdded = new Image();
imageAdded.onload = function (img) {
var imgAdded = new fabric.Image(imageAdded, {
clipName: picID,
clipTo: function (ctx) {
return _.bind(clipByName, imgAdded)(ctx)
}
});
canvas.add(imgAdded);
imgAdded.on("object:selected", function (e) { // It doesn't pass this function
alert(e.target.clipName + " is selected");
e.target.clipTo = null;
canvas.renderAll();
});
};
- I want to alert when I select an object but no alert is showed because the function where I made a ment in the code doesn't work.
- I tried this link but still can't make it possible.
I appreciate every suggestion. Thank you!
Share Improve this question edited May 23, 2017 at 11:44 CommunityBot 11 silver badge asked Jan 6, 2016 at 3:10 MesMes 1774 silver badges13 bronze badges1 Answer
Reset to default 5If you want an event for a specific object use:
imgAdded.on("selected", function(){alert(this.clipName);});
if want event for canvas and all objects:
canvas.on("object:selected", function(e){alert(e.target.clipName);});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745144512a4613585.html
评论列表(0条)