• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Starting window instead of a new untitled document? [Simple SOLUTION]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Starting window instead of a new untitled document? [Simple SOLUTION]


  • Subject: Re: Starting window instead of a new untitled document? [Simple SOLUTION]
  • From: James Bucanek <email@hidden>
  • Date: Wed, 2 Aug 2006 11:23:15 -0700

James Bucanek wrote on Monday, July 31, 2006:
>I'd like to implement a "getting started" window that prompts the user to create a new file
>or open an existing one. I want this window to appear ONLY when the application is started without
>opening an existing document. Searching the archives, the advice has been to create this window in
>applicationWillFinishLaunching:. But I don't want to see the window every time. I only want it to
>appear if the application was launched without a document to open.

For future generations searching the archives, the answer turned out to be much simplier than I had originally thought. I just wasn't thinking "high" enough in the framework.

You really only have to override one method in the application's delegate:

    - (BOOL)applicationOpenUntitledFile:(NSApplication*)application
    {
        [quickStartWindowController openWindow];
        return (YES);
    }

That's it! This message is only sent on application startup or reactivation, and only if there are no other open windows in your application. (Not just document windows, any open window will suppress it.)

Be sure to return YES every time (even if you don't open the window for some reason) or post-10.4 frameworks will continue looking for alternate methods of opening an untitled document.

This also assumes that you have not overridden applicationShouldOpenUntitledFile, which should return YES. I let applicationShouldOpenUntitledFile return the user preference to suppress the display of my quick start window.

Optionally, you can override applicationShouldHandleReopen:hasVisibleWindows: if you want to prohibit applicationOpenUntitledFile: from being called when your application is reactivated by clicking on its icon in the dock.

--
James Bucanek
 _______________________________________________
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

  • Prev by Date: Re: (Newbie) Multiple views in a Core Data app
  • Next by Date: Vertical alignment images in an attributed string
  • Previous by thread: looking for detroit/ann arbor area cocoa developers
  • Next by thread: Vertical alignment images in an attributed string
  • Index(es):
    • Date
    • Thread