如何通过功能防止激活的 mousedown 事件?
How to prevent activated mousedown event by function?
function itext(){
function addText() {
canvas.on('mouse:up', function(options) {
var left1=Math.round(options.e.clientX)-139;
var top1=Math.round(options.e.clientY)-250;
var newText = new fabric.IText("",{
left:left1,
top:top1
});
canvas.add(newText);
canvas.setActiveObject(newText);
newText.enterEditing();
newText.selectAll();
});
}
canvas.on('mouse:down', addText);
}
我想在单击 canvas.i 时向 canvas 添加一些 itext 使用此 function.after 执行此功能,mouseevent 应该是 disabled.but 我不知道如何防止激活 mouseevent.any idea/example 会被 appreciated.thank 你
像 e.PreventDefault
这样的东西应该可以工作,它会阻止默认的点击操作表单通过,所以你的函数应该只在每次点击时触发一次
在执行函数之前将布尔变量设置为 false。然后你的函数检查它是否为真,如果为真则什么也不做。如果它是假的,那么它会做你想做的并将变量设置为真。这样只执行一次。
function itext(){
function addText() {
canvas.on('mouse:up', function(options) {
var left1=Math.round(options.e.clientX)-139;
var top1=Math.round(options.e.clientY)-250;
var newText = new fabric.IText("",{
left:left1,
top:top1
});
canvas.add(newText);
canvas.setActiveObject(newText);
newText.enterEditing();
newText.selectAll();
});
}
canvas.on('mouse:down', addText);
}
我想在单击 canvas.i 时向 canvas 添加一些 itext 使用此 function.after 执行此功能,mouseevent 应该是 disabled.but 我不知道如何防止激活 mouseevent.any idea/example 会被 appreciated.thank 你
像 e.PreventDefault
这样的东西应该可以工作,它会阻止默认的点击操作表单通过,所以你的函数应该只在每次点击时触发一次
在执行函数之前将布尔变量设置为 false。然后你的函数检查它是否为真,如果为真则什么也不做。如果它是假的,那么它会做你想做的并将变量设置为真。这样只执行一次。