Reputation: 177
How do i cancel the close event from a com.smartgwt.client.widgets.Window ? I need the user confirmation to close the window, i saw that the class com.smartgwt.client.widgets.tab.events.TabCloseClickEvent have a cancel method that stops the action, i need the same for the com.smartgwt.client.widgets.events.CloseClickHandler. How do i implement this feature?
Upvotes: 2
Views: 2545
Reputation: 313
I found that if you don't immediately cancel the event (because it's waiting for user input) then the window closes anyway. Here is what I found worked if you need to wait for user input.
window.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClickEvent event) {
event.cancel();
StringBuilder b = new StringBuilder();
b.append("<BR>");
b.append("Are you sure you want to close?");
SC.ask("Close", b.toString(), new BooleanCallback() {
@Override
public void execute(Boolean value) {
if (value) {
window.close();
}
}
});
}
});
Upvotes: 0
Reputation: 1
In your window object
myWindowObject.addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(CloseClickEvent event) {
//Do whatever
if(IHaveTOCancel){
event.cancel();
}
}
});
Upvotes: 0
Reputation: 2389
public HandlerRegistration addCloseClickHandler(CloseClickHandler handler)
Handles a click on the close button of this window. The default implementation hides the window and returns false to cancel bubbling. Override this method if you want other actions to be taken.
Upvotes: 1