On 7 mai, 23:14, Ed <[email protected]> wrote:
> Hellu,
>
> I am trying to get a better understanding of the event bubbling and
> canceling an event:
> 1) Does all gwt events bubble up? even if the parent itself doesn't
> support the gwt event?

http://code.google.com/webtoolkit/doc/1.6/FAQ_UI.html#How_can_I_efficiently_handle_events_from_many_interior_Widgets?
links to PPK's excellent writeup on the subject.
See also http://www.slideshare.net/pp.koch/voices-that-matter-javascript-events

...and the answer is "no", not all DOM events bubble; and AFAICT GWT
doesn't bubble "logical" events.

> So a Panel should receive the focus event of contained textbox?

no, because the focus event doesn't bubble.

> 2)  Suppose I have panel with a textbox and I am the only one that add
> a listener to the textbox. Is it safe and better to call
> event.stopPropagation() in the listener in this case?
> With safe I mean; does anybody else might need the event, like for
> example the KeyUpEvent, that I cancel? (maybe the (root) browser-
> display itself .......

Someone could always use the capture phase (NativePreviewEvent/
NativePreviewHandler) and see the events, so calling stopPropagation
isn't probably worth it.

> Any idea about the  performance difference if you have "many" widgets
> in case you cancel the event?

I do believe bubbling is somehow optimized by browsers, as this is the
"normal" behavior; so I doubt stopPropagation would really make a
difference (though I have no numbers).
More importantly, I think you should only use stopPropagation on
purpose, to make your code easier to understand, thus to maintain (uh,
why did I prevent bubbling of this event 2 months ago? there must have
been a good reason, but which one?).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to