On Sunday, May 12, 2013 9:30:48 AM UTC+2, Ranjith Chungath wrote:
>
> I have a cell which is composed of multiple div, img eleemnts. When I 
> register for mouse in/out events, 
> onBrowserEvent gets called multiple times when the mouse is hovered over 
> the cell because it fires for each contained div/img elements.
>  
> I know that this is done so that there might be a requirement to want to 
> know exactly which element was moused over. 
>  
> But, in my case , I don't need to know which contained element was moused 
> over, I just want to know which cell was moused over. These multiple events 
> are making my implementation complex since I have having to do a lot of 
> book keeping.
>  
> What is the best way to implement this? Also, it will be great if you can 
> point me to some examples.
>

You'll want to test whether the "related event 
target"<http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/dom/client/NativeEvent.html#getRelatedEventTarget()>
 (the 
element the mouse is exiting for a mouseover, or the one it's entering for 
a mouseout, the reverse of the "event target") is a child of the cell's 
root element (or is the root element).

   - if the mouse enters the cell, it receives a mouseover event whose 
   related event target is another element: process the event
   - if the mouse (still over the cell) enters a child element, you'll have 
   a mouseover event whose related event target is the cell root element: 
   ignore the event
   - if the mouse (still over the cell) moves from one child element A to 
   another (not nested) child element B, you'll have a mouseout whose related 
   event target is B and a mouseover whose related event target is A: ignore 
   both
   - if the mouse exits B but stays over the cell, it receives a mouseout 
   whose related event target is the cell root element: ignore the event
   - if the mouse exits the cell, it receives a mouseout event whose 
   related event target is another element: process the event

That work is already done in Widget so you only get events when the mouse 
enters or leaves the widget as whole: 
https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/client/ui/Widget.java#163
 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to