Open window on dock icon click?

So I’ve got my fun little single window applescript studio app, but when I close the window, I can’t get the wiondow to come back up again without restarting the app. I’ve searched around and can’t seem to find the answer to the question:

How to I get my window to launch when I click the dock icon? (ala address book, ical, itunes, etc)

In your NIB, attach the “activated” handler to the application (file’s owner) then in your AppleScript, add this code:

Now, if you close the main window, whenever you activate the app, which is what you are doing when you click on the icon in the dock, the main window will show. Adjust the window name as necessary.

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

works like a charm. Thanks.

ok – a followup question. How do I make the window pop up when I’ve close the window, but haven’t switched off of the application. It’s still active, so the ‘activate’ doesn’t catch it. I’ve played around with some off the actions, but can’t seem to find it. Any suggestions?

Just attach a “will close” or “should close” handler to your window in IB then in your script, in that handler, add a call to show a window.

Jon