how to fire a customized event.

10 views
Skip to first unread message

wahaha

unread,
Sep 14, 2011, 3:52:02 AM9/14/11
to Google Web Toolkit
in a user-defined widget,i defined a event.
i want to fire the event,when i click on the child widget.
how to imple this?

Thomas Broyer

unread,
Sep 14, 2011, 4:59:55 AM9/14/11
to google-we...@googlegroups.com
Widget#fireEvent? (how about looking at how things are done in existing widgets? look specifically for the com.google.gwt.event.logical.shared.* events)

Ali Thabet

unread,
Sep 14, 2011, 5:58:32 AM9/14/11
to google-we...@googlegroups.com
If your goal is to do a treatment when the event occurs on the child widget you must implement the corresponding interface in your custom Widget. for example:

public class MyWidget extends Composite implements HasClickHandlers
{
    private TextBox text = new TextBox();

    private PushButton button = new PushButton("MyButton");

    public MyWidget()
    {
         ....
         initWidget(...);
     }

     @Override
   public HandlerRegistration addClickHandler(ClickHandler handler)
   {
      return button.addClickHandler(handler);
   }
}
Reply all
Reply to author
Forward
0 new messages