'load nib' required before 'show window' after closing window?

Hi,

I’m having a little trouble with the showing and hiding windows.

When the program launches, my MainMenu nib is automatically loaded with all the windows I need. At some point the user makes a request to bring up a window and I use ‘show window’ to show the window that was loaded from the nib.

But it appears that when the user clicks the go-away box of that window, it causes the window to unload from memory. If they request the window again and I try to use “show window” it fails.

If I use ‘load nib’ before calling ‘show window’ everything works just fine.

THE QUESTIONS:
Is there a simple way to tell the window NOT to unload when it’s closed?
Can I stop the window from closing and then tell it to hide instead?
Do I have to always load the nib before showing it?

Always loading the nib seems a little counter intutitive since I would then need a different nib for every window type just so I could load it (and it alone) before showing the window.

Thanks,
Colin.

I’m having (I think) the same problem. The app crashes with a SIGSEV error when a window is reopened. Pretty much the most annoying thing ever.

Try attaching a should close handler in the window’s Show Info–>AppleScript pane:

on should close theObject
	tell theObject to hide
end should close

I thought the additional line return false might be required, but on cursory experimentation it seems to work either way (maybe return false would be necessary if the hide command were implemented in a will close handler?)

should close!
Brilliant!
Thanks!
Worked like a charm.

I had tried returning false from ‘will close’ but to no avail.

Thanks again,
Colin.

See this thread: http://bbs.applescript.net/viewtopic.php?id=11150

Jon

Wonder why it seems to work for me without the return false?

Edit: D’oh! Maybe because I’m not running Tiger…

It sounds like – actually…

I was going to say that it sounded like the “Release when closed” attribute might have been set for the panel or window in question.

Maybe you could send the window or panel an extra retain message? Not sure how you’d do it in AS, but in Obj C it’d be

(given the following outlet):
IBOutlet NSWindow *mainWindow;

[mainWindow retain];

or possibly

[[mainWindow retain] autorelease];

Then you wouldn’t have to worry about manually releasing it at a later time…

Model: G4 400 @ 450 (oc’d) 1 GB RAM
Browser: Safari 412
Operating System: Mac OS X (10.4)