2008/6/24 Keith Hughitt <[EMAIL PROTECTED]>:

> On a similar note, anyone know a way to watch for double right-clicks?
> I can stop the context-menu from opening, and pick up double-left
> clicks
> easily enough, but the right clicks seem to be counted as discrete
> clicks, and never a single 'double-click.'
>
> On Apr 24 2007, 6:55 am, "Richard Quadling" <[EMAIL PROTECTED]>
> wrote:
> > Just reading through the patches for this in Trac
> > (
> http://dev.rubyonrails.org/changeset/6537andhttp://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 adouble-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!"
>

Hi.

You sent this directly to me, rather than the group.

I updated my script a little (attached) to monitor doubleclicks.

I've also attached a results page.

I hope you all get similar results.

Richard.
-- 
-----
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
-~----------~----~----~----~------~----~------~--~---

Title: Testing clicking
Left, Right or Middle click me!
Title: Mouse click monitoring with Prototype
Mouse click monitoring with Prototype
The following code was used as the test bed for these results:
<html>
<head>
<script src=""></script>
<script type="text/_javascript_">
function clicking(e) {
  commonUpdate(e, 'clicked');
}
function doubleclicking(e) {
  commonUpdate(e, 'doubleclicked');
}
function commonUpdate(e, s) {
  $('clicker').update(
    $('clicker').innerHTML + '<br />' +
    'You ' + s + ' with your ' +
    (e.isLeftClick() ? 'Left' : '') +
    (e.isRightClick() ? 'Right' : '') +
    (e.isMiddleClick() ? 'Middle' : '') +
    ' button. e.button = ' + e.button +
    ' and e.which = ' + e.which
  );
}
</script>
<title>Testing clicking</title>
</head>
<body>
<span id="clicker">Left, Right or Middle click me!</span>
<script type="text/_javascript_">
document
  .observe('click', clicking)
  .observe('dblclick', doubleclicking);
</script>
</body>
</html>
Results
This is the things I found.
[SINGLE CLICK] or [DOUBLE CLICK]
IE7 Safari 3.1.1 Opera 9.5 Firefox 3.0
Single Left Click [BLANK] / 0 /undefined [LEFT] / 0 / 1 [LEFT] / 0 / 1 [LEFT] / 0 / 1
Single Middle Click [BLANK] / 0 / undefined [BLANK] / 1 / 2 Nothing [MIDDLE] / 1 / 2
Single Right Click Context Menu only Context Menu only Context Menu only 2[RIGHT] / 2 / 3
Double Left Click [BLANK] / 0 / undefined
[BLANK] / 0 / undefined
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
[LEFT] / 0 / 1
Double Middle Click [BLANK] / 0 / undefined 1[BLANK] / 1 / 2 Nothing 3[MIDDLE] / 1 / 2
[MIDDLE] / 1 / 2
[MIDDLE] / 1 / 2
Double Right Click Context Menu only Context Menu only Context Menu only 2[RIGHT] / 2 / 3
[RIGHT] / 2 / 3
[RIGHT] / 2 / 3
1 Sometimes I get [LEFT] / 1 / 2
2 The Context Menu is also shown
3 It has to be a slow double click

Reply via email to