Modal Windows

Ok I am able to make a window modal by using:

theapp's runModalForWindow_(thewindow)

But once the window is modal how do you allow other actions to happen automatically? I am tying to make a dialog appear when the user wants to reset all preferences back to the defaults. So when they do this, a modal window appears and shows a spinner while the application resets. So how do I call other actions after the modal session began and how do I end the modal session?

I presume you end it with stopModal() or abortModal(). but do you really need a modal window? Can you instead just hide the other window for the duration?

stopModal() and abortModal() don’t return an error when they are used but they are not ending the modal session for the window. Once theapp’s beginModalSessionForWindow_(thewin) is invoked the modal works and the code after that line continues to be executed but when the code gets to stopModal() the modal doesn’t stop.

I believe stopModal and abortModal only work if you use runModalForWindow (which doesn’t allow code to execute after, you must have a button to press to end it using stop or abort modal) If I’m wrong here how would you code the stopModal() to end the modal for the window?

I’ve looked at this documentation online but haven’t been able to get any of the code to work for me in applescript other than beginModalSessionForWindow.
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/WinPanel/Concepts/UsingModalWindows.html

I think you’re going to have to find another way of achieving what you want. You can’t use beginModalSessionForWindow_ because the NSModalSession it returns is is a struct, not a pointer, but ASObjC turns it into a pointer. Hence you can’t set up a modal loop for it.