Thanks!! That was all what I needed..
On Jan 14, 12:18 am, Thomas Broyer <[email protected]> wrote: > On 13 jan, 21:42, Youngster <[email protected]> wrote: > > > I can't find out how to replace the deprecated event.getTarget(). > > I have the following code: > > > @Override > > public void onBrowserEvent(Event event) { > > Element target = event.getTarget(); > > if (DOM.eventGetType(event) == Event.ONCLICK) { > > for (Widget widget : widgets) { > > if (widget.getElement() == target) { > > .... > > > Now event.getTarget says: Deprecated. use NativeEvent.getEventTarget() > > instead. > > Element target = event.getEventTarget().cast(); > > (if you shift+click or ctrl+click in Eclipse, you'll see that it's > exactly what Event.getTarget() > does:http://code.google.com/p/google-web-toolkit/source/browse/releases/2.... > ) > > > Can anyone tell me how test on which widget was clicked, using > > NativeEvent.getEventTarget() ?? > > Your code above will fail if any widget contains a child element (in > case this child element is clicked, widget.getElement() will be false > for all widgets). > Try using Node.isOrHasChild() instead of comparison for equality > (though there might be another, better/faster, algorithm) > > > And another question: why should I use onBrowserEvent for a Composite? > > Is it not better/easier to implement HasClickHandlers? Which one > > should be used when? > > ClickHandler (assuming you meant ClickHandler rather than > HasClickHandlers) will add a class (unless the composite implements it > directly, which isn't a good idea in most, if not all, cases). > onBrowserEvent is lighter-weight, but also a bit "lower level". None > is "better" than the other, so I'd suggest you to use the one you find > "easier" (you're the most comfortable with)
-- 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.
