Web view stops working after closing window

I think this is my first question. I always seem to find answers without ever having to ask, 'till now:

I have a web view in a window that is working just fine with a URL field hooked up and everything, following the tutorial in Shane’s wonderful book. The problem I’m having is when I close the window and re-eopen it, the web view is blank and it no longer loads. I think I’ve tried every combination of window behavior and memory options in IB.

Thanks,
Greg

I came up with a workaround but I’d still be interested in understanding why this happens. I rebuilt it just to see if I did something wrong and got the same result. The difference from the tutorial is that the webview and toolbar are in a second window separate from the main application window.

I disabled the close button and added my own button that I connected to orderOut: instead of performClose: which I assume is what the close button does. Now it performs as expected but it has an odd blemish of a disabled close button and a button next to it that says “Close”. Kind of like one of those cars you see with a broken tail-light and a trailer tail-light duct-taped over it.

Try turning off Release When Closed and One Shot for the window.

Yes, tried all those buttons on and off. I think Release When Closed should be renamed Make Window Useless. I guess I don’t understand what it’s supposed to do.

Try making your script the delegate of the window, and adding this:

on windowShouldClose_(sender)
	sender's performSelector_withObject_afterDelay_("orderOut:", missing value, 0)
	return no
end windowShouldClose_

I believe release when closed refers to the memory for the window. As in “release the memory” so the window does not exist any more (not just “invisible”) and must be re-instantiated from fresh.

Shane - your idea worked great, but I got an error:

“unable to set argument -1 - the AppleScript value <NSAppleEventDescriptor: 'no '> could not be coerced to type c.”

It did work though. I changed the “return no” to “return false” and it worked without giving me an error.

SMG - I figured it was something like that. Some of those window behaviors and memory settings are kind of mysterious to me.

Thanks!

Yep; got my booleans crossed.