Re: Document-based app
Re: Document-based app
- Subject: Re: Document-based app
- From: Laurent Michel <email@hidden>
- Date: Fri, 30 Dec 2005 14:43:09 -0500
On Dec 29, 2005, at 10:00 AM, Camillo Lugaresi wrote:
On 29/dic/05, at 05:38, Laurent Michel wrote:
Hi!
A quick question.
I am writing a Document based app. When the app starts, it creates
an "Untitled" document. On the first "Open" request, a new window
is created to host the chosen document. All of this works fine.
However, one 'reviewer' pointed out that this is not how
"TextEdit" (for instance) behaves. Indeed, on the first "open"
request, the chosen document replaces the content of the
"Untitled" window.
So,... how should I go about replicating that behavior of
textEdit? Subclassing NSDocumentController?
Any pointer is most welcomed.
I think what TextEdit does is this:
- if it's launched without any documents, it creates a new empty
document as usual, but it also sets a flag;
- if the new file is edited, the flag is cleared;
- if an open request arrives, and the flag is still set, the empty
untitled document is close, the requested document is opened in its
place, and the flag is cleared.
Camillo
Thanks a bunch!
With your answer and Irina's pointer, I managed to replicate the
exact behavior of textEdit. closing the untitled document and
reopening was not perfect though (flashing of the two windows), so in
the end I sub-classed the the NSDocumentController and used your
suggested scheme togeter with calls to changed the URLname of the
untitled document and to reload its content. It worked like a charm.
Thanks again,
--
Laurent
_______________________________________________
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