Re: How to create a modal dialog that blocks on start-up?
Re: How to create a modal dialog that blocks on start-up?
- Subject: Re: How to create a modal dialog that blocks on start-up?
- From: "Sean McBride" <email@hidden>
- Date: Fri, 6 Mar 2009 12:41:29 -0500
- Organization: Rogue Research Inc.
On 3/6/09 4:01 PM, Graham Cox said:
>Actually the problem is more complicated than this.
>
>The app might have been launched with a file or files, or just by
>double-clicking. So if the EULA needs to be displayed this should just
>defer opening the required documents. By stopping the untitled or
>other files from opening, they never do.
>
>The apple events that supply the launch files or otherwise need to be
>captured (for later resending) or deferred, a the moment they are
>either discarded or processed, neither of which is appropriate.
>
>This is WAY too hard.
I actually used a DTS incident on this very issue. As you say, it is
hard to get exactly right (if you want finesse). In the end, I got
about 90% of the way to perfect.
I ended up doing the following:
- subclassing NSDocumentController
- giving it 2 modes: normal and queuing
- in normal mode it works like super
- in queuing mode, I queue any kAEPrintDocuments and kAEOpenDocuments
that I receive
- I set it to queue mode in applicationWillFinishLaunching (which is
before any kAEPrintDocuments/kAEOpenDocuments arrive)
- in applicationDidFinishLaunching I show my splash screen
- at this point the user may try to open or print documents, but I don't
want them to appear, but nor do I want them to be lost
- when OK is clicked in the splash screen, I end queuing mode and
process items in the queue
- if there are no items in the queue I call [self
openUntitledDocumentAndDisplay:error:]
- if there are items in the queue I call [super
openDocumentWithContentsOfURL:display:error:]
- also I implement applicationShouldOpenUntitledFile to return yes if
I'm in normal mode, and no if I'm in queuing mode.
This all works well for kAEOpenDocuments, but not so well for
kAEPrintDocuments. The problem is that in
openDocumentWithContentsOfURL:display:error: (where I conditionally add
to the queue) I have no way to know if its an kAEPrintDocuments or a
kAEOpenDocuments. My app doesn't actually print, so I gave up at that point.
Would be nice if NSApplication had a delegate message like
applicationWillFinishLaunching that gives you a chance to show a modal
ok/cancel dialog at launch. Please create a dupe. :)
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden