Skip navigation.
 
mlRe: one document at a time
FROM : Jeff LaMarche
DATE : Tue Dec 14 23:22:18 2004

On Dec 14, 2004, at 5:07 PM, Jiri Volejnik wrote:

> I need to modify my app so that only one document at a time can be
> opened. If there is some document already opened, it should be closed
> and its windows reused. What way would you suggest to go? I was
> thinking about subclassing NSDocumentController, but maybe it's not
> necessary?


Well, before anything, I'd suggest you think through this. As an end
user, I find the one-document restriction annoying in most applications
that use it. I have trouble seeing why Quicktime Player allows multiple
movies, but Windows Media Player allows only one, for example. There
are some cases where it seems to make sense, though.

So, if you're sure it's the right thing to do, I would suggest that the
easiest thing is to simply gray the "new document" menu item when a
document is opened or created, and enable it when there a document is
closed. With the "open document" option, you should ask to save, close
without saving, or cancel before presenting the standard open dialog.

This requires a relatively minimal amount of code, and is fairly easy
to back out should you decide to support multiple documents in the
future.

Related mailsAuthorDate
mlone document at a time Jiri Volejnik Dec 14, 23:07
mlRe: one document at a time Jeff LaMarche Dec 14, 23:22
mlRe: one document at a time Jiri Volejnik Dec 14, 23:28
mlRe: one document at a time Jonathon Mah Dec 15, 12:33
mlRe: one document at a time Jiri Volejnik Dec 15, 13:43
mlRe: one document at a time Steven Kramer Dec 15, 14:59