Re: Prevent default alert when quitting app w/ many unsaved docs
Re: Prevent default alert when quitting app w/ many unsaved docs
- Subject: Re: Prevent default alert when quitting app w/ many unsaved docs
- From: "Louis C. Sacha" <email@hidden>
- Date: Fri, 17 Dec 2004 16:35:16 -0800
Hello...
You can subclass NSDocumentController and override the
reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:
method. You would probably completely override the original
implementation of the method, and could move your custom validation
code there, or just short circuit the default implementation by
invoking the callback selector in the delegate (and passing the
context info) and then returning.
In order to have your NSDocumentController subclass be used for the
application's shared instance, you will need to instantiate an
instance of your subclass in the main nib file for your application
or in the applicationWillFinishLaunching: app delegate method, as
described in the conceptual documentation
<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Tasks/SubclassController.html>.
Hope that helps,
Louis
When the user quits a document based application that has many
unsaved documents, the default Cocoa behavior is to present an alert
box saying something like "You have N documents with unsaved
changes. Do you want to review these changes before quitting?". The
dialog lets you "Discard Changes", "Cancel", or either "Review
Changes..." where you'll be guided to the unsaved docs one by one.
Is there a way to prevent this alert to open at all? I would like to
code my own logic, and I actually did in applicationShouldTerminate:
of my NSApp delegate, but that is called after the default dialog.
So basically I get 2 dialogs now.
I know I could find a workaround to open my own dialog only in the
cases not handled by the default alert box, but this seems like a
situation where there is a standard way of doing things that I'm not
getting.
Am I missing something ?
Thanks in advance,
--Ettore
_______________________________________________
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