Any comments on this? ---------- Forwarded message ---------- From: Richard Quadling <[EMAIL PROTECTED]> Date: 24-Apr-2007 11:55 Subject: Re: [Rails-spinoffs] Re: Observing the Right-click (for good, not evil) To: [EMAIL PROTECTED]
Just reading through the patches for this in Trac (http://dev.rubyonrails.org/changeset/6537 and http://dev.rubyonrails.org/ticket/7520). I've added some notes there to explain my code. I've tested this on WinXP SP2 with IE7, Opera9 and FF2. All with slightly different results. On 24/04/07, Richard Quadling <[EMAIL PROTECTED]> wrote: > Hi. > > I didn't realise that the Event.button and Event.which values were > different 'tween IE and FF. > > <html> > <head> > <script type="text/javascript" > src="/global/javascript/prototype/prototype.js"></script> > <script type="text/javascript"> > function clicking(e) > { > alert > ( > 'You clicked with your ' + > (Event.isLeftClick(e) ? 'Left' : '') + > (Event.isRightClick(e) ? 'Right' : '') + > (Event.isMiddleClick(e) ? 'Middle' : '') + > '. Event.button which was ' + e.button + > ' and Event.which was ' + e.which > ); > } > function extendEvent() > { > Object.extend > ( > Event, > { > WHICH_LEFT: (navigator.appVersion.match(/\bMSIE\b/)) ? 1 : 1, > WHICH_RIGHT: (navigator.appVersion.match(/\bMSIE\b/)) ? 1 : 3, > WHICH_MIDDLE: (navigator.appVersion.match(/\bMSIE\b/)) ? 1 : 2, > MOUSE_LEFT: (navigator.appVersion.match(/\bMSIE\b/)) ? 1 : 0, > MOUSE_RIGHT: (navigator.appVersion.match(/\bMSIE\b/)) ? 2 : 2, > MOUSE_MIDDLE: (navigator.appVersion.match(/\bMSIE\b/)) ? 4 : 1, > > isLeftClick: function(event) > { > return (((event.which) && (event.which == Event.WHICH_LEFT)) || > ((event.button) && (event.button == Event.MOUSE_LEFT))); > }, > > isRightClick: function(event) > { > return (((event.which) && (event.which == Event.WHICH_RIGHT)) || > ((event.button) && (event.button == Event.MOUSE_RIGHT))); > }, > > isMiddleClick: function(event) > { > return (((event.which) && (event.which == Event.WHICH_MIDDLE)) || > ((event.button) && (event.button == Event.MOUSE_MIDDLE))); > } > } > ); > } > </script> > <title>Testing clicking</title> > </head> > <body> > <span id="clicker">Left, Right or Middle click me!</span> > <script type="text/javascript"> > Event.observe(document.body, 'mousedown', clicking); > Event.observe(window, 'load', extendEvent); > </script> > </body> > </html> > > This is sort of working in IE and FF. In IE I don't get the context > menu but I do in FF (IE7 and FF2.0.0.3) > > I think that the middle and right button detection should be added to > Prototype. The current Left button detection is flawed according to my > tests as Event.button == 0 for Left. > > I hope this makes some sense. > > Richard. > > > > > > On 23/04/07, Walter Lee Davis <[EMAIL PROTECTED]> wrote: > > > > And this fails in Safari, with a work-around posted on Trac of "just > > don't use Event.Observe..." which is icky. > > > > Click it is... > > > > Walter > > > > On Apr 23, 2007, at 11:54 AM, Walter Lee Davis wrote: > > > > > Maybe I'll just > > > try using a double-click instead... > > > > > > > > > > > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---