Re: One window for all documents.
Re: One window for all documents.
- Subject: Re: One window for all documents.
- From: Chaz McGarvey <email@hidden>
- Date: Tue, 10 May 2005 08:19:16 -0600
On May 10, 2005, at 6:11 AM, Darkshadow wrote:
On May 10, 2005, at 2:54 AM, Chaz McGarvey wrote:
Program design question: My theoretical app can open files with
extension "foo" and I would like to have the benefits of
NSDocument. However, I want a single window with an NSTableView
to contain a list of "open" documents. This shared window will be
used to display information from the file. The list is updated as
foo files are opened. In order to edit the file, you double-click
an item from the shared window and a document window comes up. So
basically, the shared window just sits there display information
about the documents that are open, and the other windows are the
document windows which need the benefits of NSDocument, like
saving. This scenario probably isn't very exciting or innovative.
In order for this to work, an NSDocument has to be able to stay
loaded even when it has no windows on-screen for it. The problem
is that the NSDocument is automatically released when the
'document' window closes. I could do something like feed it a
dummy window controller so it thinks it should stick around, but
I've found that whenever I'm tempted to do something ugly like
this, there usually is a better, more appropriate way. Any
insights? I'm tired.
Well, you could keep a reference to the file path or URL in the
objects that represent opened documents in the table view. Then
if the document is closed, don't remove it from the list and double
clicking will just have that document open again.
If that won't work for you (maybe it takes a while to open
documents or some such thing), I suppose you can just send the
window -orderOut: - it'll disappear from the screen but stay
around. This'll use more memory, though. If you go this route,
you may want to make sure the document gets saved if there are any
changes to it before ordering it out, otherwise you may run into
issues where if the user tries to quit and a window just suddenly
appears asking if changes want to be saved or not.
Darkshadow (aka Michael Nickerson)
The thing I like about keeping the NSDocument around as opposed to
just a reference to the file is NSDocument's ability to detect when
the file moves and automatically ask the user the right questions.
NSWindow's orderOut: seems like a decent solution, but NSDocument
shows the window by default and I would want the document to first
appear in the shared window and only open the document windows when
they are called for.
Thanks very much for your thoughts. I'll keep poking around.
chaz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden