[Tip] Preventing a dialog from closing
by Marcel Trapman
www.it2be.com
Sometimes you don't want the user to be able to close a dialog other than via the buttons you place on the form (dialog). You can do this by attaching methods to the onHide event, onShowForm event, your OK button and your Cancel button. Here are the methods:
onShow
trigger = null;
I define a form variable 'trigger' and set it to null to begin with.
onHide
if (!trigger) {
return false;
}
Here I tell the form not to hide itself if the variable 'trigger' is null, "" or 0...
selectedCancel
trigger = "cancel";
application.closeFormDialog();
The cancel button is triggered and the variable 'trigger' is set to the value 'cancel'. Because 'trigger' is not emply anymore the evaluation in the onHide event will not return false.
selectedOK
your own code;
trigger = "ok";
application.closeFormDialog();
In fact this is the same as the method for the cancel button except that you will put in the code that needs to be executed here before you close the dialog.
One important thing before testing this: ENABLE THE DEBUGGER... If you don't and your code is wrong there is nothing left but to cancel Servoy Developer with a force quit.
Cheers,
Marcel
Comments (2)