我当前正在使用最新版本的Fabric.js,即1.4.0。现在可以使用Itext对象进行文本编辑。每当编辑IText对象时,我都想执行一些操作。到目前为止,我已经找到modified
和moving
事件,但是它们的工作方式与我希望的不同。
canvas.on('object:modified', function(e) {
//do something, maybe count the number of characters
});
它们仅在移动对象时起作用。无论如何,只要Itext的文本发生更改,我们是否可以执行某些操作?即...使用1.4.0中提供的新功能,即直接文本编辑。非常感谢你。
对于任何寻求答案的人,在Xenyal的答案中添加了更多信息,我发现最新版本的fabric.js版本text:changed
在画布下不支持。
使用(最新发布版本)http://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.4.0/fabric.min.js
whatevertext.on("text:changed", function(e) {
//this works with the latest release build where whatevertext is the name of the object
});
使用(开发版本)https://rawgit.com/kangax/fabric.js/master/dist/fabric.js
canvas.on('text:changed', function(e) {
//this will only work using the dev build
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句