Include a halt script step for every method you are enabling for closeing the window. Buttons can specify this in button setup in the current script drop down. Scripts can make this the last step in the script. You can use a custom menu to update the close window menu option to run a script that both closes the window and then usess halt script to halt the paused script. (And I'd put the pause inside an infinite loop so the user can't continue the script by just pressing the enter key.)
Centering one window on another is a matter of correctly computing the top and bottom values for the New Window command based on the position and size of both windows.
Get functions can be used capture the size and position of the first window and put the values in variables before you open the new window.
$LeftOldWindow + $WidthOldWindow/2 - $WidthNewwindow/2
Would calculate the left edge of your new window to horizontally center it, to give one example.
I originally had my close button on my popup set to Close Window. I changed it to Resume Script and that did the trick. Only potential problem I see is if somehow the script were to be exited prior the close button would then have no effect. But I don't really see how one coould exit the script. I had tried a Halt Script step at the end of each script but see that once you hit the close button there would be no way to continue the script. I think the Resume Script on the button is a pretty good option. Let me know if you have something more efficient/foolproof.
Thanks for the tip on the window. I'll play around with it.
Given how you've written that script, resume should work. There is one caveat. Is it a problem for you if the user presses the enter key? That will also resume your paused script and close the window.
If that is an acceptable result, no problem. If you don't want an enter key press to close the window then the alternative is to enclose the Pause step in side an infinite loop and then you must use Halt Script to terminate the infinite loop.
Recently, I've had to adapt a solution to work with dual monitors with a different window open in each monitor. Since show custom dialog does not provide me with a way to control where it will open, I've had to replace all the show custom dialog steps with my own sub script that uses new window to open my own version of a message dialog in the appropriate location.
I came up with this loop:
Set Variable [$$Button ; value: "" ]
Exit Loop if [Not IsEmpty ( $$Button ) ]
The buttons are really fields with a drop shadow effect so my script can put text from a script parameter into the fields to label them. The fields are then set up as buttons with a parameter expression that passes the value of the field to a script that does this:
Set Variable [$$Button ; Get ( ScriptParameter ) ]
and these buttons have the resume option specified.
This way, I can exit the loop and then test the value of $$Button to determine which button was pressed.
But I also have a close window script that simply closes the window and terminates with Halt script that I use with a custom menu so that clicking the close control in the upper corner of the window still halts the script--and provides the functional equivalent of clicking Cancel. (It also determines whether or not to maximize windows after closing...)
I don't think hitting enter should be a problem. Might make things easier on the user.
Thanks for the tip on the loop/multi monitor. I'll keep that in my back pocket.