I want to remove the pointer-events :none property when I right click . that's what I actually tried .
HTML
<div class="wrapper">
<br />
<div id="viewer2" class="viewer" style="width:800px; height:300px; position: absolute; z-index : 0;></div>
<canvas id="paper" width="800" height="300" style="border:1px solid #ccc;position: absolute; z-index : 1;"></canvas>
<br />
</div>
Javascript
$('.viewer').bind('contextmenu', function(e) {
return false;
});
$('#paper').bind('contextmenu', function(e) {
return false;
});
document.getElementById('paper').onmousedown =FuncOnClick;
function FuncOnClick(event) {
console.log(event.which);
switch (event.which) {
case 1:
document.getElementById("paper").style.pointerEvents = "none";
alert('Left');
break;
case 3:
document.getElementById("paper").style.pointerEvents = "";
alert('Right ');
break;
}
}
What I'm trying is to check if it's right or left click and if it's right it click on the canvas and it's left it click on the div. But when I Right click the pointer-events is staying with 'none' value .
What can I do to easily remove the pointer-events attribute and do it before the click is fired (like I did in the code the click is going to click before the pointer-events is edited ?)
EDIT : Added Z-index to make it a bit clearlier
EDIT #2
My DIV contain an image that i can move with right click and zoom with mousewheel . My canvas is here because i want to draw some rectangle (region of interest) . I want to draw these rectangle with right click . When i left click i can drag my image (div) When i right click i want to draw rectangle on (canvas)
So what i need is to be able to pass trough the canvas when i right click .