As explained in the Quirksmode treatment (

http://www.quirksmode.org/js/events_mouse.html

), mouseover and mouseout are sometimes not as useful as they could be.
 One must filter out mouseover and mouseout events generated when the
mouse enters and leaves child nodes and ignore mouseouts caused by
mousing over a link- all in a sometimes complicated way.

IE has events called "mouseenter" and "mouseleave" that are simpler to
use- they don't bubble up to parent nodes.

It would be very nice if MochiKit could provide cross-browser access to
these events. I'm visualizing something like this:

 function filterForMouseEnter(e) {
     if (e.target() != this || isChildNode(e.relatedTarget(), this)) {
         e.stop();
         return;
     }
     signal(this, "onmouseenter", e);
 }

 function filterForMouseLeave(e) {
     if (e.target() != this || isChildNode(e.relatedTarget(), this)) {
         e.stop();
         return;
     }
     signal(this, "onmouseleave", e);
 }

 function registerMouseEnterAndLeave(elem) {
     if (browserAlreadyHasMouseEnterAndLeave()) {
         return function () {};
     }
     var conn1 = connect(elem, "onmouseover", filterForMouseEnter);
     var conn2 = connect(elem, "onmouseout", filterForMouseLeave);
     return function () { disconnect(conn1); disconnect(conn2); };
 }

So the idea is that you would call registerMouseEnterAndLeave on your
element when you are interested in mouseenter/mouseleave events on it.
You could then connect to those signals in the usual manner.
registerMouseEnterAndLeave would kindly provide you with a closure
which would disconnect its extra connections, if any.

I haven't tested this, and I haven't spent a lot of time working out
the details, but something like this is possible, and once I get it
right, I'll post again.

Oh, yeah, and isChildNode() would be a real nice addition too :-)

paul


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to