Actually, I tested what you suggested, a list with an inner-list (or 
submenu), to see if it would work.  Here's the html:

<ul id="list">
    <li> 1
        <ul>
            <li>0</li>
        </ul>
    </li>
    <li> 2
        <ul>
            <li>0</li>
            <li>1</li>
        </ul>
    </li>
    <li> 3
        <ul>
            <li>0</li>
            <li>1</li>
            <li>2</li>
        </ul>
    </li>
</ul>

<script type="text/javascript">
    $("list").observe("mouseout",  function(e) {
        if(Position.within($("list"), Event.pointerX(e), 
Event.pointerY(e))) return;
       alert("list out");
    });
</script>

It worked flawlessly.  The alert box was only thrown when you leave the 
area of the ul#list, not when you leave any of the inner items or lists.

 - Dash -


Jean-Philippe Encausse wrote:
> Interresting !
>
> In fact I have developped a very complicated Contextual Menu, with
> multiple <ul><li>.
>
> Because of this strange behavior, on mouseout, I set a timeout before
> closing the menu.
>
> Then if the mouse movein quickly the menu stay opened like an OS Menu.
>
> There is one issue with your solution, you might have to check if
> mouse is on a submenu (sub UL/LI) ?
>
>
> On 5/11/07, David Dashifen Kees <[EMAIL PROTECTED]> wrote:
>   
>> Well done.  I hadn't thought of that.  Thanks for sharing!
>>  - Dash -
>>
>> Sudara wrote:
>>     
>>> Hello.
>>>
>>> I spent an hour or three chasing down a desired effect that mootools
>>> implements, namely the simulation of onmouseleave and onmouseenter
>>> events.
>>>
>>> Why?
>>>
>>> Lets say you have a Menu. A ul element that contains many li elements.
>>> If you want to have a function (maybe an effect) fire when the mouse
>>> moves outside of the ul, you are out of luck. Observe the mouseout
>>> function like so:
>>>
>>> Event.observe(nav, 'mouseout', function(e) {
>>>       // you would think this would work
>>>       alert('mouse is outside of nav?...');
>>> });
>>>
>>> and what actually happens is that every time the mouse leaves the
>>> element OR crosses the boundary of a child element (li), the event is
>>> fired.
>>>
>>> Instead of implementing onmouseleave/onmouseenter the way that
>>> mootools has it, I saw that the sweet prototype API has a Pointer
>>> class.
>>>
>>> I'm still a bit green with Prototype, but my answer came in this
>>> shape:
>>>
>>> Event.observe(nav, 'mouseout', function(e) {
>>>       if(!Position.within(nav,Event.pointerX(e),Event.pointerY(e))){
>>>               alert('...mouse is now truly outside nav...');
>>>               });
>>>       }
>>> });
>>>
>>> Have a good day!
>>> Sudara
>>>
>>>
>>>       
>>>       
>
>
>   

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