Close Window Separates Script from Object

In AppleScript Studio / Xcode 2.0 (461) on Mac OS X 10.4, closing a window (either programmatically or by clicking the close widget) causes the window to lose its AppleScript information. It will no longer respond to the events it is linked to (such as “will open” or “will close”) and its AppleScript name property is changed to its title property. This seems like a major bug and has halted my AppleScript Studio development for 10.4 completely. Help!

Here’s a demo project to demonstrate the issue:

http://homepage.mac.com/jonn8/as/dist/CloseWindow.zip

Can anyone using Xcode 2.0/ Mac OS X 10.4 confirm this? Anyone have a workaround?

Thanks,
Jon

FYI, Apple knows about this:

on 5/4/05 11:52 PM, John Coelho at @apple.com wrote:

Hi Jon,

This is a known bug that we have a fix for already and should be
available a future release. Here are some relevant notes from the
Tiger AppleScript Studio release notes:

In Tiger, the “Release when closed” NSWindow attribute in Interface
Builder is not honored. The window object is always released
regardless of how this attribute is set.

The workaround is not to close the window, but instead to hide it if
you want to keep it around. You can do this by adding an on should
close handler to your application as shown in the following example:

on choose menu item theObject
show window “Main”
end choose menu item

on should close theObject
hide window “Main”
return false
end should close

The lesson? Read the release notes. The AppleScript Studio release notes are buried and I just read the Xcode release notes. Hopefully this will help someone else.

Jon

This helped immensly

I kept wondering when the following occurred

I Load Nib for the window
do something with the data in the table view for the window
close the window (cliicking the red dot)

reopened the window

Voila! The table was blank.

When i added


tell theObject to hide
return false

to should close handler for the window everything worked.

awful work-around. Wonder if it will come back to bite me with some other handler that does not play nicely with the should-close handler.

hmmm

Jann