thanks TJ, i noticed kangax coded a really nice right click menu.. now 
normally i would use somehting like this but i need the menu to be filled 
with an ajax request response .. perhaps i will hack his to peices and see 
what i can do !!!!!!!


Alex
----- Original Message ----- 
From: "T.J. Crowder" <t...@crowdersoftware.com>
To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com>
Sent: Tuesday, May 05, 2009 11:14 AM
Subject: [Proto-Scripty] Re: Catching right click



Hi,

Right-click is a bit of a pain. :-)  Mostly, browsers fire the
'contextmenu' event instead of 'click', but not all browsers do and
not all browsers allow you to replace (e.g., prevent) the default
action of bringing up the context menu.  (Opera is a particular
problem; I think recent versions have a config setting allowing the
user to allow you to do it, but the default is off, so...)  This page
[1] on quirksmode gives you an idea of support across browsers.

Browsers seem quite reliable about firing 'mousedown' and 'mouseup' on
right-clicks (even Opera, but don't get excited, stopping the default
on mousedown or mouseup doesn't stop the context menu).  You can use
Event#isRightClick to see if it's a right-click (note that !
Event#isLeftClick doesn't mean it's a right-click, it could be a
middle-click).  Apparently Event#isRightClick and Event#isMiddleClick
are missing from the API docs, but they're in Prototype 1.6.0.3 and
1.6.1 RC2 (at least).  Really those methods should be isLeftButton,
isRightButton, and isMiddleButton as they work regardless of whether
it's a "click", but never mind.

Here's a quick-and-dirty test page for mouse events you can play with.
[2]

[1] http://www.quirksmode.org/dom/events/contextmenu.html
[2] http://pastie.org/468536

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On May 5, 9:28 am, Jeztah <webmas...@thecarmarketplace.com> wrote:
> I need to catch the right click of a mouse in an element...
> Unfortunately i am at a bit of a halt ....
>
> $('myDiv').observe('click', function(event) {
>
> if(!Event.isLeftClick(event)) {
> alert('Right Click'); // doesnt work in firefox
> Event.stop(event); // doesnt work in firefox
> } else {
>
> alert('Left Click');
> }});
>
> can anyone point me in the right direction ?
>
> Ta
> Alex



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to