There's only one event fired, and that is when the popup closes. All popups do is open and close, and since you have to open them programmatically, you know when this happens.
On the other hand, popups can be closed automatically if you so choose, when the user clicks outside the popup. In this case, you might need to pick this event up. That is what this listener lets you do.
In this demo, we make the class into a listener for not only the popup, but the button as well. There are a number of ways of adding listeners. Have a look at the ClickListener page if you need some examples.
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PopupListener;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.roughian.rxf.client.ui.AbstractRemotePage;
public class Listeners__PopupListener extends AbstractRemotePage implements PopupListener, ClickListener
{
Button button = new Button("Show Popup", this);
PopupPanel popup = new PopupPanel(true);
public void buildPage()
{
VerticalPanel panel = new VerticalPanel();
panel.setStyleName("table-center");
HTML html = new HTML("Click outside to close");
popup.setStyleName("demo-popup");
popup.add(html);
popup.addPopupListener(this);
panel.add(button);
RootPanelUncached.get("demo").add(panel);
}
public void onPopupClosed(PopupPanel sender, boolean autoClosed)
{
button.setEnabled(true);
}
public void onClick(Widget sender)
{
button.setEnabled(false);
popup.center();
}
}