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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees
2007-Apr-23 13:39 UTC
Re: Observing the Right-click (for good, not evil)
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://prototypejs.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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://prototypejs.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> 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://prototypejs.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> 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://prototypejs.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Apr-23 15:11 UTC
Re: Observing the Right-click (for good, not evil)
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-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Apr-23 15:12 UTC
Re: Observing the Right-click (for good, not evil)
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-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 -~----------~----~----~----~------~----~------~--~---
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-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org >> >>> > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees
2007-Apr-23 16:26 UTC
Re: Observing the Right-click (for good, not evil)
Can you use Event.stop() to keep the context menu from appearing? - Dash - Walter Lee Davis wrote:> 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-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org >>> >>> >> > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The event that is passed along is mousedown, not contextmenu. I am stopping the passed event (which is mousedown) but that does not keep the contextmenu event from firing at all. Walter On Apr 23, 2007, at 12:26 PM, David Dashifen Kees wrote:> > Can you use Event.stop() to keep the context menu from appearing? > - Dash - > > Walter Lee Davis wrote: >> 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-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org >>>> >>>> >>> >> >> >>> >> >> > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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...--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> 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!" --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> 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 <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> 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!" --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---