我可以在触发事件时获取jQuery响应,但是fabric canvas不会对该事件做出反应。
我希望这个小例子可以取消选择IText元素。 fiddle 我知道fabric canvas有一个触发事件,但它也没有起作用。
我希望这个小例子可以取消选择IText元素。 fiddle 我知道fabric canvas有一个触发事件,但它也没有起作用。
var canvas = new fabric.Canvas("c");
var test = jQuery("#c");
test.on("mouse:down", function (){
alert("you clicked me");
canvas.renderAll();
debugger;
});
canvas.on({"mousedown": function() {
alert("you clicked me too");
}});
$("#testClick").click(function() {
var e = jQuery.Event("mouse:down", {
pageX: 10,
pageY: 10
});
jQuery(canvas).trigger(e);//Missed - not jquery
jQuery(jQuery("#c")).trigger(e);
jQuery(test).trigger(e);
});
/*************** TEXT ****************/
var text = new fabric.IText('FaBric.js', {
fontSize: 40,
textAlign: 'center',
fontWeight: 'bold',
left: 128,
top: 128,
angle: 30,
originX: 'center',
originY: 'center',
shadow: 'blue -5px 6px 5px',
styles: {
0: {
0: {
fontSize: 60,
fontFamily: 'Impact',
fontWeight: 'normal',
fill: 'orange'
}
}
}
});
text.setSelectionStyles({
fontStyle: 'italic',
fill: '',
stroke: 'red',
strokeWidth: 2
}, 1, 5);
canvas.add(text);
canvas.setActiveObject(text);
编辑 1
我尝试使用“mouse:down”和“click”事件,但对象不会取消选择:fiddle 2