PDA

View Full Version : Right click on viewport/canvas



Achilles4689
06-06-2011, 08:54 PM
When a user right clicks an object in my game I would like to be able to have a menu come up. Is it possible to override the right click event only for the canvas and still allow normal right click functions outside of the canvas?

Thanks,
Achilles

zed
06-07-2011, 09:39 PM
document.onmousedown = handleMouseDown;

function handleMouseDown(event){

if ( mouse_pos ) inside gl canvas
return false;
else
return true;
}

true = menu comes up
false = no menu

Achilles4689
06-08-2011, 10:49 PM
Thanks zed. Very helpful!

-Achilles