On Aug 28, 2009, at 2:54 AM, Ken Thomases wrote:

On Aug 27, 2009, at 2:49 PM, Dylan McNamee wrote:

Which hook should I use to detect that my document-based app has been launched without a document having been dropped on it (or double-clicked upon)?

Right now my app just launches and shows its menu.

What I'd like to do is catch this case, and at least pop up an "Open" dialog.

A document-based app will automatically open a new untitled document under those circumstances, by default. To make it not do that, you have to return NO from the Application delegate's - applicationShouldOpenUntitledFile: method. Naturally, if you want to not open a new untitled document but also do something else, you should have that method do the "something else" and also return NO.

You should also pay attention to the - applicationShouldHandleReopen:hasVisibleWindows: delegate method if you want to do something different on first launch vs. the user "relaunching" your app (by double-clicking it in the Finder or click on its Dock icon) when it's already running.

This advice pointed me in the right direction. A detail I forgot to share, which is what threw me off the correct track is that my application (Cheap Impostor) is a "read-only" document-based application, so the notion of "OpenUntitledFile" didn't make sense to me -- there's no notion of opening a blank document for creation. However, this hook (and its associated event applicationOpenUntitledFile:) is exactly the place where I wanted to launch the Open Dialog, and it works great.

Thanks very much!
dylan
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to