Class DelegatingClickListenerCollection

public class DelegatingClickListenerCollection
extends ClickListenerCollection
implements ClickListener
ClickListenerCollection used to correctly hook up listeners which need to listen to events from another source.

For example, Composite widgets often need to listen to events generated on their wrapped widget. Upon the firing of a wrapped widget's event, the composite widget must fire its own listeners with itself as the source of the event. To use a DelegatingClickListenerCollection, simply use the DelegatingClickListenerCollection instead of a ClickListenerCollection. For example, in SuggestBox, the following code is used to listen to click events on the SuggestBox's underlying widget.

  public void addClickListener(ClickListener listener) {
    if (clickListeners == null) {
      clickListeners = new DelegatingClickListenerCollection(this, box);
    }
    clickListeners.add(listener);
  }

Constructors

DelegatingClickListenerCollection(Widget, SourcesClickEvents)Constructor for DelegatingClickListenerCollection.

Methods

onClick(Widget)Fired when the user clicks on a widget.

Constructor Detail

DelegatingClickListenerCollection

public DelegatingClickListenerCollection(Widget owner, SourcesClickEvents delegatedTo)
Constructor for DelegatingClickListenerCollection.

Parameters

owner
owner of listeners
delegatedTo
source of events

Method Detail

onClick

public void onClick(Widget sender)
Fired when the user clicks on a widget.

Parameters

sender
the widget sending the event.