On Sep 14, 2014, at 13:36 , Luc Van Bogaert <[email protected]> wrote:

> when I close the panel and reopen it again, it seems that the panel has lost 
> a reference to the document and it doesn't display the document's properties 
> anymore.

Actually, I meant to suggest it was a *bad* idea to put the panel in the 
document’s windowControllers. That was on the assumption that the panel is 
app-global, but if you’re creating one panel per document, then I don’t see a 
problem.

Since you’ve added the panel to windowControllers, it’s going to behave (in 
lifetime terms) just like a kind of document window. So, even though it doesn’t 
close the document, closing the panel will cause the panel to be removed from 
windowControllers and discarded. When the user redisplays the inspector, you’d 
have to create a new panel and panel window controller, and manually add it to 
windowControllers. (That’s not even a hacky thing to do. You just have to 
remember to do it.)

Alternatively, you could have the document keep a separate reference to the 
panel window controller. Then you wouldn’t need to re-create the inspector 
later, but you could just add its window controller back into windowControllers 
and show the panel window again.

Alternatively, you could arrange things so that “closing" the panel doesn’t 
actually close it, but rather just does an orderOut: on the window. Later, you 
can just show it again.

A couple of things to pay attention to:

— Watch the aesthetics of the timing of things when the document closes. If you 
mess around with the panel lifetime, it may stay visible for longer than you 
want.

— Watch the Window menu’s window list. You probably want a customized menu item 
for the panel, and you want to make sure that the panel’s item appears then 
when and only when it looks right. (Specifically, you might want the panel item 
there when its document is frontmost, regardless of whether the panel is 
visible, but you wouldn’t want items for other document’s panels then. This is 
going to depend on what other menu items you have for hiding or showing panels. 
You may not want the inspector in the Window menu window list at all.)


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to