Any dialog derived from UIFrame and displayed with the Display() method and not the Pose() method will do exactly that.
However, when displaying such a modeless dialog your other code will just continue to run. The dialog is on a separate thread.
This is the opposite of a modal dialog which will wait for it to be closed before code execution resumes.
So, if you want a script, that presents a dialog, allow "doing stuff" but then continues when the dialog closes, things are a bit more complicated to do.
You can only do this when you script is on a background thread.
Examples:
Simple, blocking, modal dialog:
clearResults()
Result("I do stuff \n")
OKDialog("Wait for me!")
Result("I continue to do stuff \n")
Simple, modeless dialog. Only works for scripts on a background thread:
// $BACKGROUND$
number ModelessTwoButtonDialog(string prompt, string but1, string but2)
{
number sem = NewSemaphore()
ModelessDialog(prompt,but1,but2,sem)
Try{GrabSemaphore(sem);}
Catch{return 0;}
return 1
}
clearResults()
Result("I do stuff \n")
number res = ModelessTwoButtonDialog("Wait for me!","OK","CANCEL")
Result("I continue to do stuff. You pressed:" + res)
Simple, modeless dialog that will not block your script execution. (But dialog buttons may do stuff).
class myDlg:UIframe{
void OnButtonDoStuff(object self) { result("\n Action!"); }
myDlg(object self)
{
taggroup dlg = DLGCreateDialog("My Dialog")
dlg.DLGAddElement(DLGCreateLabel("just text in this dialog"))
dlg.DLGAddElement(DLGCreatePushButton("DO stuff", "OnButtonDoStuff"))
self.Init( dlg )
}
}
clearResults()
Result("I do stuff \n")
Alloc(myDlg).display("Title")
Result("I continue to do stuff.")
Simple, modal dialog that will block your script execution. (But dialog buttons may do stuff).
class myDlg:UIframe{
void OnButtonDoStuff(object self) { result("\n Action!"); }
myDlg(object self)
{
taggroup dlg = DLGCreateDialog("My Dialog")
dlg.DLGAddElement(DLGCreateLabel("just text in this dialog"))
dlg.DLGAddElement(DLGCreatePushButton("DO stuff", "OnButtonDoStuff"))
self.Init( dlg )
}
}
clearResults()
Result("I do stuff \n")
Alloc(myDlg).pose()
Result("I continue to do stuff.")
Simple, modeless dialog that will block your script execution until closed. (But dialog buttons may do stuff).
(The script on the main-thread is constantly telling DM to do other stuff as long as the window is open. A bit ugly.)
class myDlg:UIframe{
void OnButtonDoStuff(object self) { result("\n Action!"); }
myDlg(object self)
{
taggroup dlg = DLGCreateDialog("")
dlg.DLGAddElement(DLGCreateLabel("just text in this dialog"))
dlg.DLGAddElement(DLGCreatePushButton("DO stuff", "OnButtonDoStuff"))
self.Init( dlg )
}
~myDlg(object self){Result("\n Dialog actually removed from memory.");}
}
clearResults()
Result("I do stuff \n")
documentwindow win = Alloc(myDlg).display("Title")
while (win.WindowIsOpen()) doEvents()
Result("I continue to do stuff.")
win = NULL