[Proto-Scripty] Re: Catching right click

2009-05-05 Thread Alex McAuley

So'k i had my head in places it shoulnt be ... (at least for firefox  - 
still working on a x-browser solution)


For those of you that wondered what the solution was ...
$('foo').observe('contextmenu', function(event) {

if(Event.isRightClick(event)) {
 event.stop();

alert('I Was right clicked');
 }

});



- Original Message - 
From: "Alex McAuley" 
To: 
Sent: Tuesday, May 05, 2009 2:03 PM
Subject: [Proto-Scripty] Re: Catching right click


>
> After hacking to pieces Kangax's right click menu i discovered it is not 
> the
> right thing for me
>
> however i cannot see why the following code does not work seeing as i pass
> event to the anonymous function/..
>
> $('foo').observe('click', function(event) {
> // alert(event); // alerted as a mouse Event as expected
> event.stop(); // doesnt stop the event
>console.log('Stopped Context Menu ' + event.isRightClick()); // 
> only
> logs left clicks
>event.stop(); // doesnt stop the event
>
> });
> according to your Pastie link TJ, this code should work as its just a
> simpler version of it (in essence logging to console true or false of a 
> left
> or right click.) it seems FF 3.010 (last update was thursday iirc) it
> does not work on.
>
> Am i using event.stop() wrong ? because Event.stop(event); does not work
> either
>
> Thanks in advance
>
> Alex
>
>
>
>
> ----- Original Message - 
> From: "T.J. Crowder" 
> To: "Prototype & script.aculo.us" 
> 
> 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  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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Catching right click

2009-05-05 Thread Alex McAuley

After hacking to pieces Kangax's right click menu i discovered it is not the 
right thing for me

however i cannot see why the following code does not work seeing as i pass 
event to the anonymous function/..

$('foo').observe('click', function(event) {
// alert(event); // alerted as a mouse Event as expected
event.stop(); // doesnt stop the event
console.log('Stopped Context Menu ' + event.isRightClick()); // only 
logs left clicks
event.stop(); // doesnt stop the event

});
according to your Pastie link TJ, this code should work as its just a 
simpler version of it (in essence logging to console true or false of a left 
or right click.) it seems FF 3.010 (last update was thursday iirc) it 
does not work on.

Am i using event.stop() wrong ? because Event.stop(event); does not work 
either

Thanks in advance

Alex




- Original Message - 
From: "T.J. Crowder" 
To: "Prototype & script.aculo.us" 
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  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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Catching right click

2009-05-05 Thread Alex McAuley

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" 
To: "Prototype & script.aculo.us" 
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  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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Catching right click

2009-05-05 Thread T.J. Crowder

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