How do I make my app quit when I close its window?

Yesterday I created an AS Studio interface to my dictionary scripts. It took most of the day, lots of mistakes and redos. I always feel a little beaten up after doing something new like this. I got the various popup menus and text views working with one exception – the search field. Is it possible in AS Studio to create a drop down menu to select the field to search a la Mail’s search field?

The main question I have now is how to make my app quit when I close its window. How do you do that?

I think I may have started with a document-based app and switched to a single window (it was a long day). Plus, I experimented with connecting different scripts to certain IB structures and may have done something that prevents me from getting the on-should-quit script from working. Was I supposed to connect an interface element to that script?

one strategy would be to connect all windows to the “Will Close” handler, and test there if there is only one window open.

more elegant strategies may exist.

No, all you have to do is add the “should quit after last window closed” handler to the application (File’s Owner) in IB and then in your main script, return true from the handler itself:

on should quit after last window closed theObject
    return true
end should quit after last window closed

Jon

Thanks! It was the “return true” I was missing.

Now, can you tell me how to add a panel-window to the NIB?

(I hate asking stupid questions like these – I looked through the fora and searched the IB documentation first, honest I did)

Try splitting this off into another thread (to aid those who search for this subject in the future)… Or, a moderator could do this for you.