Tuesday, September 28, 2010

How to add click handler to a panel?

I want to add a click handler to a panel so I extended the
HorizontalPanel as shown below. It feels dirty because in the
constructor I have to register the click event but put nothing in the
method in order for the ClickEvent to propgate to the parent control
which registers the ClickHandler. Is this the correct way of doing it
or am I being a hacker?


public class HorizontalPanelSoho extends HorizontalPanel implements
HasClickHandlers {

public HorizontalPanelSoho(){
this.addDomHandler(new ClickHandler(){

//This has to be here otherwise event doesn't get passed up to the
handler registered.
public void onClick(ClickEvent event) {

}, ClickEvent.getType());

public HandlerRegistration addClickHandler(ClickHandler handler) {
return addHandler(handler, ClickEvent.getType());

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

No comments:

Post a Comment