Reputation: 1336
I have a PopupPanel
private PopupPanel simplePopup;
The popup opens in the app. When the user clicks outside of it the popup is closed. This is the default behaviour. I'd like to override that behaviour and DON'T close the popup IF a condition is met. I have something like this in mind:
simplePopup.addCloseHandler(new CloseHandler<PopupPanel>() {
@Override
public void onClose(CloseEvent<PopupPanel> arg0) {
if (conditionIsMet) {
// do something here to avoid closing the popup
}
}
});
But I don't know how to prevent the popup from closing. I've read something about onPreviewNativeEvent but I don't know how to use it.
Upvotes: 0
Views: 1619
Reputation: 895
You need to disable the autoHide flag. The default hide behavior is due to this flag. You can disable it with the following code snippet.
simplePopup.setAutoHideEnabled( false );
You can also disable it through constructor.
You can control the hide based on some condition by overridding the hide method as
simplepopup = new PopupPanel( false)
{
@Override
public void hide( boolean autoClosed )
{
if( condition met )
{
super.hide();
}
}
};
Upvotes: 2