I didnt ask 1st.. Is there any special reason to use the
addEventListener(...) instead of mootools addEvent(...)

This code works for me:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html>
<head>
<title></title>
<script type="text/javascript"
src="assets/scripts/mootools-1.2-core.js"></script>
<script type="text/javascript"
src="assets/scripts/mootools-1.2-more.js"></script>
<script>
function clicked(e)
{
        if(e.button == 2){
                console.debug('right clicked');
        } else {
                console.debug('left clicked');
        }
}

window.addEvent('domready',function(){

        var d = new Element('div',{
                'styles' : { 'border' : '1px solid #999', 'height' : 300, 
'width' : 400}
        }).injectInside(document.body);
        
        // change d to document to show right click detection
        //d = document; <-- if uncommented, right triggers twice...
        d.addEventListener('click', clicked, false);
        d.addEventListener('contextmenu', clicked, false);

});
</script>
</head>
<body>
</body>
</html>

Reply via email to