On 22 juil, 21:07, Kriptonis Azullis <[email protected]> wrote:
> Hello, I'm developing an application using gwt . I never used events
> before so I am still learning how they work in GWT.
>
> The sinkEvents() as I understand it is used if you want your widget to
> react to events.
First, starting with GWT 1.6, you don't have to deal with sinkEvents
in your code, just use addDomHandler vs. addHandler.
addDomHandler calls sinkEvents in addition to calling addHandler.
sinkEvents registers handlers for the appropriate events on the DOM
element used by the Widget (see Widget#getElement()). When such an
event is fired (on the DOM, generally "by" the browser), it's handled
by Widget#onBrowserEvent which just delegates it to the handlers you
registered. The only exception is mouseover/mouseout events, which are
only ever delegated to the handlers if they actually go in and out of
the Widget#getElement() (i.e. not from a child element to another
child element).
If you know how DOM events work (bubbling, capture, cancelable, etc.),
GWT doesn't change that.
> But what does it do to events if it doesn't handle
> them?
Nothing special.
> Does it bubble them up so that other widget can try to handle them? Or
> if I do sinkEvents() on a widget it keeps all events from passing?
If the event bubbles, it does so at the DOM level, so it'll be
dispatched to parent widgets too, if they listen to them (i.e. they
called sinkEvents too for those event types)
> When I fire a event does it propagate along the widgets until
> something handles it?
If you do fire it at the DOM level, it'll bubble the DOM tree.
> For example, if I have a image inside a vertical panel, and that panel
> is inside a Absolute panel. When the image fires a clickevent, if the
> vertical panel does nothing to it, will it propagate to the Absolute
> panel?
Yes, but neither VerticalPanel or AbsolutePanel give you the
opportunity to register a ClickHandler, so you won't be able to handle
the event at this higher level in the widget tree.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---