Modal SHeet in AppleScript Studio app

Hey there

I have a little app I am writing in AppleScript Studio, and I have created a panel that is shown, as a sheet attached to the main window, which contains an error message for my error handling.

My problem is, when creating the sheet, the application carries on processing the rest of the script.

What I need is a way to make the application wait until the sheet is dismissed before continuing, much in the same way that you would get if you used display dialog.

Please can anymore help me out? I’ve not been having much luck with this, and I’d really like to get it working, since the rest of the app is pretty much done.

So in summary I need the application to wait for a sheet to close before continuing.

Thanks in advance

That’s the behavior of the display command. If you read the panel docs, specifically the section about using the display command you’ll see that opening a custom panel attached to another window makes is document modal, and it does NOT stop execution of the script. What you need to do, is break up your script and put everything that happens after the panel is shown into the “panel ended” handler. This handler is called after, uh, the panel ended, and allows you to both catch the panel ending and to find out what, if any state (result) the panel had when it closed.


Hey there

Thanks for the reply.

I had a feeling that was the reason.

I’m not sure I can split up the script and put the rest of it in the panel ended bit, because the panel is being used to display a nicely formatted error message, and is called from within a repeat loop at the moment.

So I’m not sure if it is possible to do this another way, by pausing a window or something?


You may wish to try display dialog as addressed within

I discovered that

display window "sheet name" attached to "window name"

did work without all the funny work-around I engineered in the above link (towards that page’s very bottom).