preventDefault on mouse up

662 views Asked by At

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

There are 1 answers

0
Nistor Cristian On BEST ANSWER

You can add:

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

outside of canvas.on('mouse:up' ...

See jsFiddle