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 <[EMAIL PROTECTED]> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to