|
List Info
Thread: Observing the Right-click (for good, not evil)
|
|
| Observing the Right-click (for good,
not evil) |
  United States |
2007-04-23 08:20:58 |
I have a bit of code that invokes the In Place Editor when
you
right-click on a div:
var rightClick = function(e){
var field = this.id;
var tall = Math.ceil(Element.getHeight(this)/24);
tall = (tall > 30)? 30 : tall;
Event.stop(e);
var editListing = new Ajax.InPlaceEditor(field,
"ajax_update.php", {
rows:tall,cols:50,
onComplete: function(transport, element) {
new Effect.Highlight(element, {
startcolor: this.options.highlightcolor
});
editListing.dispose();
},
loadTextURL: "get_raw.php?id=<?= $id
?>&class=<?= $class ?>&field=" +
field,
ajaxOptions: {
method: "post"
},
callback: function(form, value) {
return "id=<?= $id ?>&class=<?= $class
?>&field=" + field +
"&myparam=" + encodeURIComponent(value)
}
});
if(editListing) editListing.enterEditMode('click');
};
var editThis = function(){
//alert('boo');
Event.observe('title','contextmenu',rightClick);
Event.observe('intro','contextmenu',rightClick);
Event.observe('body_text','contextmenu',rightClick);
};
Event.observe(window,'load',editThis);
This all works great -- on a Mac. But I just tried on
Windows, and
apparently the contextmenu bit is not enough to trigger the
function on
IE6 (haven't tried IE7 yet).
What do I need to add to my Event.observe call to capture
the
right-click event on the Other platform?
Thanks in advance,
Walter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  United States |
2007-04-23 08:39:53 |
Prototype provides a handy isLeftClick() function as a part
of the Event
object extensions that you can use. Plus, if I understand
the API
correctly, isLeftClick() doesn't actually refer to the left
button but
rather the button that doesn't ivoke the context menu thus
providing
support for both left-handed and right-handed mice.
http://p
rototypejs.org/api/event/isLeftClick
-- Dash --
Walter Lee Davis wrote:
> I have a bit of code that invokes the In Place Editor
when you
> right-click on a div:
>
> var rightClick = function(e){
> var field = this.id;
> var tall = Math.ceil(Element.getHeight(this)/24);
> tall = (tall > 30)? 30 : tall;
> Event.stop(e);
> var editListing = new Ajax.InPlaceEditor(field,
"ajax_update.php", {
> rows:tall,cols:50,
> onComplete: function(transport, element) {
> new Effect.Highlight(element, {
> startcolor: this.options.highlightcolor
> });
> editListing.dispose();
> },
> loadTextURL: "get_raw.php?id=<?= $id
?>&class=<?= $class ?>&field=" +
> field,
> ajaxOptions: {
> method: "post"
> },
> callback: function(form, value) {
> return "id=<?= $id ?>&class=<?=
$class ?>&field=" + field +
> "&myparam=" + encodeURIComponent(value)
> }
> });
> if(editListing) editListing.enterEditMode('click');
> };
> var editThis = function(){
> //alert('boo');
> Event.observe('title','contextmenu',rightClick);
> Event.observe('intro','contextmenu',rightClick);
> Event.observe('body_text','contextmenu',rightClick);
> };
> Event.observe(window,'load',editThis);
>
> This all works great -- on a Mac. But I just tried on
Windows, and
> apparently the contextmenu bit is not enough to trigger
the function on
> IE6 (haven't tried IE7 yet).
>
> What do I need to add to my Event.observe call to
capture the
> right-click event on the Other platform?
>
> Thanks in advance,
>
> Walter
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  United States |
2007-04-23 08:50:31 |
Thanks. It just took a moment to look through the
looking-glass and do
this instead of trying to observe the right-click:
var rightClick = function(e){
if(Event.isLeftClick(e)) return;
...
and observe the 'click' instead of 'contextmenu'.
Walter
On Apr 23, 2007, at 9:39 AM, David Dashifen Kees wrote:
> Prototype provides a handy isLeftClick() function as a
part of the
> Event
> object extensions that you can use. Plus, if I
understand the API
> correctly, isLeftClick() doesn't actually refer to the
left button but
> rather the button that doesn't ivoke the context menu
thus providing
> support for both left-handed and right-handed mice.
>
> http://p
rototypejs.org/api/event/isLeftClick
>
> -- Dash --
>
> Walter Lee Davis wrote:
>> I have a bit of code that invokes the In Place
Editor when you
>> right-click on a div:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |

|
2007-04-23 08:52:49 |
Looking at prototype.js V1.5.0, Lines 2200-2203, the
isLeftClick
method's owner, Event, could easily be extended by ...
Object.extend(Event, {
isRightClick: function(event) {
return (((event.which) && (event.which == 1))
||
((event.button) && (event.button ==
2)));
},
isMiddleClick: function(event) {
return (((event.which) && (event.which == 1))
||
((event.button) && (event.button ==
4)));
}
});
The event.button values are
0 No button is pressed.
1 Left button is pressed.
2 Right button is pressed.
3 Left and right buttons are both pressed.
4 Middle button is pressed.
5 Left and middle buttons both are pressed.
6 Right and middle buttons are both pressed.
7 All three buttons are pressed.
On 23/04/07, David Dashifen Kees <dashifen dashifen.com> wrote:
>
> Prototype provides a handy isLeftClick() function as a
part of the Event
> object extensions that you can use. Plus, if I
understand the API
> correctly, isLeftClick() doesn't actually refer to the
left button but
> rather the button that doesn't ivoke the context menu
thus providing
> support for both left-handed and right-handed mice.
>
> http://p
rototypejs.org/api/event/isLeftClick
>
> -- Dash --
>
> Walter Lee Davis wrote:
> > I have a bit of code that invokes the In Place
Editor when you
> > right-click on a div:
> >
> > var rightClick = function(e){
> > var field = this.id;
> > var tall =
Math.ceil(Element.getHeight(this)/24);
> > tall = (tall > 30)? 30 : tall;
> > Event.stop(e);
> > var editListing = new
Ajax.InPlaceEditor(field, "ajax_update.php", {
> > rows:tall,cols:50,
> > onComplete: function(transport,
element) {
> > new
Effect.Highlight(element, {
> > startcolor:
this.options.highlightcolor
> > });
> > editListing.dispose();
> > },
> > loadTextURL:
"get_raw.php?id=<?= $id ?>&class=<?=
$class ?>&field=" +
> > field,
> > ajaxOptions: {
> > method: "post"
> > },
> > callback: function(form, value) {
> > return "id=<?= $id
?>&class=<?= $class ?>&field=" + field
+
> > "&myparam=" +
encodeURIComponent(value)
> > }
> > });
> > if(editListing)
editListing.enterEditMode('click');
> > };
> > var editThis = function(){
> > //alert('boo');
> >
Event.observe('title','contextmenu',rightClick);
> >
Event.observe('intro','contextmenu',rightClick);
> >
Event.observe('body_text','contextmenu',rightClick);
> > };
> > Event.observe(window,'load',editThis);
> >
> > This all works great -- on a Mac. But I just tried
on Windows, and
> > apparently the contextmenu bit is not enough to
trigger the function on
> > IE6 (haven't tried IE7 yet).
> >
> > What do I need to add to my Event.observe call to
capture the
> > right-click event on the Other platform?
> >
> > Thanks in advance,
> >
> > Walter
> >
> >
> > >
> >
> >
>
> >
>
--
-----
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 "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  United States |
2007-04-23 09:00:32 |
Even cooler than my solution. Thanks!
Walter
On Apr 23, 2007, at 9:52 AM, Richard Quadling wrote:
>
> Looking at prototype.js V1.5.0, Lines 2200-2203, the
isLeftClick
> method's owner, Event, could easily be extended by ...
>
> Object.extend(Event, {
> isRightClick: function(event) {
> return (((event.which) && (event.which ==
1)) ||
> ((event.button) && (event.button ==
2)));
> },
> isMiddleClick: function(event) {
> return (((event.which) && (event.which ==
1)) ||
> ((event.button) && (event.button ==
4)));
> }
> });
>
> The event.button values are
>
> 0 No button is pressed.
> 1 Left button is pressed.
> 2 Right button is pressed.
> 3 Left and right buttons are both pressed.
> 4 Middle button is pressed.
> 5 Left and middle buttons both are pressed.
> 6 Right and middle buttons are both pressed.
> 7 All three buttons are pressed.
>
>
>
>
>
> On 23/04/07, David Dashifen Kees <dashifen dashifen.com> wrote:
>>
>> Prototype provides a handy isLeftClick() function
as a part of the
>> Event
>> object extensions that you can use. Plus, if I
understand the API
>> correctly, isLeftClick() doesn't actually refer to
the left button but
>> rather the button that doesn't ivoke the context
menu thus providing
>> support for both left-handed and right-handed
mice.
>>
>> http://p
rototypejs.org/api/event/isLeftClick
>>
>> -- Dash --
>>
>> Walter Lee Davis wrote:
>>> I have a bit of code that invokes the In Place
Editor when you
>>> right-click on a div:
>>>
>>> var rightClick = function(e){
>>> var field = this.id;
>>> var tall =
Math.ceil(Element.getHeight(this)/24);
>>> tall = (tall > 30)? 30 : tall;
>>> Event.stop(e);
>>> var editListing = new
Ajax.InPlaceEditor(field,
>>> "ajax_update.php", {
>>> rows:tall,cols:50,
>>> onComplete: function(transport,
element) {
>>> new
Effect.Highlight(element, {
>>> startcolor:
this.options.highlightcolor
>>> });
>>> editListing.dispose();
>>> },
>>> loadTextURL:
"get_raw.php?id=<?= $id ?>&class=<?=
>>> $class ?>&field=" +
>>> field,
>>> ajaxOptions: {
>>> method: "post"
>>> },
>>> callback: function(form, value)
{
>>> return "id=<?=
$id ?>&class=<?= $class
>>> ?>&field=" + field +
>>> "&myparam=" +
encodeURIComponent(value)
>>> }
>>> });
>>> if(editListing)
editListing.enterEditMode('click');
>>> };
>>> var editThis = function(){
>>> //alert('boo');
>>>
Event.observe('title','contextmenu',rightClick);
>>>
Event.observe('intro','contextmenu',rightClick);
>>>
Event.observe('body_text','contextmenu',rightClick);
>>> };
>>> Event.observe(window,'load',editThis);
>>>
>>> This all works great -- on a Mac. But I just
tried on Windows, and
>>> apparently the contextmenu bit is not enough to
trigger the function
>>> on
>>> IE6 (haven't tried IE7 yet).
>>>
>>> What do I need to add to my Event.observe call
to capture the
>>> right-click event on the Other platform?
>>>
>>> Thanks in advance,
>>>
>>> Walter
>>>
>>>
>>>>
>>>
>>>
>>
>>>
>>
>
>
> --
> -----
> 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 "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  France |
2007-04-23 10:11:22 |
Hey Walter,
I'm actually not aware of a x-browser way of grabbing right
clicks.
The 'contextmenu' event is not standard AFAIK, and capturing
'click' to
then use Event.isRightClick (not in trunk yet) seems to be
eluded by a
few browsers. On FF, for instance, the browser doesn't seem
to trigger
this event at all on right clicks. But I confess to not
having dived
into it seriously yet.
--
Christophe Porteneuve aka TDD
tdd tddsworld.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  France |
2007-04-23 10:12:43 |
Hey Richard,
Richard Quadling a écrit :
> Object.extend(Event, {
> isRightClick: function(event) {
> return (((event.which) && (event.which ==
1)) ||
> ((event.button) && (event.button ==
2)));
> },
> isMiddleClick: function(event) {
> return (((event.which) && (event.which ==
1)) ||
> ((event.button) && (event.button ==
4)));
> }
> });
Hang on, this has been a patch for a long time, and is
currently sitting
in the Events branch. It will show up in 1.6
--
Christophe Porteneuve aka TDD
tdd tddsworld.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |

|
2007-04-23 10:22:52 |
Really! I honestly didn't know. I just cut'n'pasted the
existing
isLeftClick, read about the value of button in my trusty old
HTML
Reference Guide and wrote a Object.extend (I've actually
added this to
my own prototype-extended.js code).
On 23/04/07, Christophe Porteneuve <tdd tddsworld.com> wrote:
>
> Hey Richard,
>
> Richard Quadling a �crit :
> > Object.extend(Event, {
> > isRightClick: function(event) {
> > return (((event.which) && (event.which
== 1)) ||
> > ((event.button) &&
(event.button == 2)));
> > },
> > isMiddleClick: function(event) {
> > return (((event.which) && (event.which
== 1)) ||
> > ((event.button) &&
(event.button == 4)));
> > }
> > });
>
> Hang on, this has been a patch for a long time, and is
currently sitting
> in the Events branch. It will show up in 1.6
>
> --
> Christophe Porteneuve aka TDD
> tdd tddsworld.com
>
> >
>
--
-----
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 "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  United States |
2007-04-23 10:39:39 |
RRRRrrrrrrrr.
You are correct, and my initial optimism was due to the fact
that my
browser had cached the previous script...
So it doesn't work at all in either (Mac) browser, and
likely doesn't
in Windoze either.
Back to the drawing board.
Do you suppose that the extensions that Richard posted would
be a
better approach?
Walter
On Apr 23, 2007, at 11:11 AM, Christophe Porteneuve wrote:
>
> Hey Walter,
>
> I'm actually not aware of a x-browser way of grabbing
right clicks.
>
> The 'contextmenu' event is not standard AFAIK, and
capturing 'click' to
> then use Event.isRightClick (not in trunk yet) seems to
be eluded by a
> few browsers. On FF, for instance, the browser doesn't
seem to trigger
> this event at all on right clicks. But I confess to
not having dived
> into it seriously yet.
>
> --
> Christophe Porteneuve aka TDD
> tdd tddsworld.com
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Observing the Right-click (for
good, not evil) |
  United States |
2007-04-23 10:54:10 |
Meanwhile, tried another tack -- If I change the event to
mousedown,
the isLeftClick test works properly, however the real
contextual menu
pops up too. It's confusing, but not completely awful. Maybe
I'll just
try using a double-click instead...
Walter
On Apr 23, 2007, at 11:39 AM, Walter Lee Davis wrote:
>
> RRRRrrrrrrrr.
>
> You are correct, and my initial optimism was due to the
fact that my
> browser had cached the previous script...
>
> So it doesn't work at all in either (Mac) browser, and
likely doesn't
> in Windoze either.
>
> Back to the drawing board.
>
> Do you suppose that the extensions that Richard posted
would be a
> better approach?
>
> Walter
>
> On Apr 23, 2007, at 11:11 AM, Christophe Porteneuve
wrote:
>
>>
>> Hey Walter,
>>
>> I'm actually not aware of a x-browser way of
grabbing right clicks.
>>
>> The 'contextmenu' event is not standard AFAIK, and
capturing 'click'
>> to
>> then use Event.isRightClick (not in trunk yet)
seems to be eluded by a
>> few browsers. On FF, for instance, the browser
doesn't seem to
>> trigger
>> this event at all on right clicks. But I confess
to not having dived
>> into it seriously yet.
>>
>> --
>> Christophe Porteneuve aka TDD
>> tdd tddsworld.com
>>
>>>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---
|
|
|
|