Saturday, January 1, 2011

Re: How to disable a custom widget and its click handlers

If you are adding multiple handlers to your button then there isn't a
propagation ... they are all sibling actions. So, what you're trying
to do wouldn't work.

I'm fairly sure the 'onBrowserEvent()' method is the initial event
handling method. You would need to override this in your custom
button class and do something like this:

@Override
public void onBrowserEvent(...) {
if(enabled) super.onBrowserEvent(...);
}

Good luck!

On Jan 1, 5:46 am, Matthew Hill <matt2...@gmail.com> wrote:
> Hi. I'm making a custom button widget.
>
> This button has a setEnabled method. When the button is disabled, clicking
> on the button must do nothing. How do I achieve this behavior?
>
> I've tried adding a Click Handler like so, to no avail:
>
> @Override
>
> public void onClick(ClickEvent event) {
>
> if (!isEnabled()) {
>
> event.stopPropagation();
>
> event.preventDefault();
>
> return;
>
>
>
> }
> }

--
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