On Tuesday, January 17, 2012 3:49:14 AM UTC+1, Cristian Rinaldi wrote:
>
> Hello:
>
> The real question is: I have a widget to inherits of ComplexWidget with 
> the following declarations:
>
> private Element root = Document.get().createDivElement();
> private LayoutPanel header = new LayoutPanel();
> private Image imgUp = new Image(getDefaultResources().imageUp());
>
> header.add(label);
> .....
> .....
> root.appendChild(header.getElement());
>

Unless you know exactly what you're doing, do not by any mean append 
widgets using their getElement(). Always put widgets inside other 
(container) widgets, otherwise the child widget's onAttach/onLoad and 
onDetach/onUnload won't be called, the events won't work, etc.
That is, when you are compositing widgets, extend Composite (or 
ResizeComposite), not Widget.

.....
> .....
> setElement(root);
> sinkEvents(Event.ONCLICK);
>
> Now I add a domHadler for image (the only event that interests me), but, 
> sinkEvents(Event.ONCLICK) register the event at level of element root, I 
> don't know how propagate the event at image, so that only the image, treats 
> you, and not the other elements of the widget.
>
> I made this:
>
> imgUp.addDomHandler(new ClickHandler() {
>
>             @Override
>             public void onClick(ClickEvent event) {
>                 header.setWidgetTopHeight(imgUp, 0, PX, 0, PX);
>                 header.setWidgetTopHeight(imgDown, 0, PX, 30, PX);
>                 collapsed = !collapsed;
>                 collapseBody(collapsed);
>             }
>         }, ClickEvent.getType());
>
> But entire the widget  treats the event.
>
> Any idea?
>

If you added you Image inside another widget (and not taking the image's 
getElement to append it to an Element), that would "just work", you 
wouldn't even need a sinkEvent(ONCLICK) at the container level.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/Q_MaJDvT1KcJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to