preventDefault on mouse up

时间:2015-06-15 14:27:41

标签: javascript contextmenu fabricjs preventdefault

this code doesn't work. How can I prevent context menu in fabrics?

canvas.on('mouse:up', function(options) {
    if(options.target){
        switch(options.e.button){
            case 0:
                // left click
                break;
            case 2:
                // right click
                options.e.preventDefault();
                break;
        }
    }
});

1 个答案:

答案 0 :(得分:1)

您可以添加:

$('canvas').contextmenu( function() {
    return false;
});

canvas.on('mouse:up'之外...

请参阅jsFiddle