Thanks for the advice. This could be a way, but I am a bit afraid that
it could be a bit risky to take this approach without knowing exactly
what one is doing. Maybe I could create some circular reference
causing memory leaks or something like that - some experienced folks
could maybe drop a word here about that, or present some safe
solution.





On 21 čnc, 03:21, Zheren <[email protected]> wrote:
> Check out GWT implementation of CustomButton.
>
> It seems that the goal can be achieved by overwrite  onBrowserEvent
> (Event event) method without using the method proposed above.
>
> FYI
>
> -Ben
>
> On Jun 23, 4:07 am,romant<[email protected]> wrote:
>
> > Ok,
> > I used just basic approach, if anyone is interested in enabling/
> > disabling click events on your
> > own composite here it is:
>
> > public class MyButton extends Composite implements HasClickHandlers,
> > ClickHandler {
>
> >     private final HashSet<ClickHandler> clickHandlers;
> >     private boolean enabled;
>
> >     public MyButton() {
> >         clickHandlers = new HashSet();
> >         addDomHandler(this, ClickEvent.getType());
> >         .......
> >         initWidget(<your_complex_widget>);
> >     }
>
> >     public HandlerRegistration addClickHandler(ClickHandlerhandler) {
> >         clickHandlers.add(handler);
> >         // don't care about the return value, nobody should need it
> >         // if necessary return some convenient class extending
> > HandlerRegistration
> >         // or create some special method for removing the clickhandlerfrom 
> > the clickHandlers list
> >         return null;
> >     }
>
> >     public void onClick(ClickEventevent) {
> >         if (enabled) {
> >             for (ClickHandlerhandler: clickHandlers) {
> >                handler.onClick(event);
> >             }
> >         }
> >     }
>
> >     public void setEnabled(boolean enabled) {
> >         this.enabled = enabled;
> >     }
>
> > }
>
> > Any suggestions for improvements are welcome.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to