• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help on implementing a ClickHandler in a GWT composite widget

 
Tapani Vuoripuomi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have been trying all day to follow the instructions given in article:
http://www.gwtsushi.info/2010/08/four-easy-steps-to-implementing.html

but cannot get it to work.

Could someone explain what I'm doing wrong?

My code is as follows:

public class CompositeEventTest implements EntryPoint {
/**
* This is the entry point method.
*/
@Override
public void onModuleLoad() {
VerticalPanel vp = new VerticalPanel();
final Label lblMessage = new Label();
EventObject eventObject = new EventObject();
eventObject.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent arg0) {
lblMessage.setText("You clicked the composite");

}

});

vp.add(eventObject);
vp.add(lblMessage);

RootPanel.get().add(vp, 10, 10);
}
}

and my composite:

public class EventObject extends Composite implements HasClickHandlers {

private final VerticalPanel mainPanel = new VerticalPanel();

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

@UiHandler("EventObject")
void doClick(ClickEvent e) {
this.fireEvent(e);
}

public EventObject() {
Button btnClick = new Button("Button");
mainPanel.add(btnClick);
mainPanel.setPixelSize(100, 100);
mainPanel.setBorderWidth(3);

// All composites must call initWidget() in their constructors.
initWidget(mainPanel);
}
}

nothing happens when I'm clicking within the border of the mainpanel, why?

Regards
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!