• 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
Starting window instead of a new untitled document?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Starting window instead of a new untitled document?


  • Subject: Starting window instead of a new untitled document?
  • From: James Bucanek <email@hidden>
  • Date: Mon, 31 Jul 2006 16:02:15 -0700

Greetings,

I have a document-based Cocoa applcation that doesn't create untitled documents (document windows can only be opened for existing document files -- which are essentially databases -- and can't exist without physical set of files).

So I've overridden newDocument: to create a file and overridden applicationShouldOpenUntitledFile: to return NO so that a new document isn't created when the user starts the application or activates it via its dock icon.

But now 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.

What's the best way to approach this?

I was thinking about the following:

    - unhook newDocument from the user interface (File > New would call a new routine to create documents).

    - rewrite newDocument so that it puts up my "getting started" window

    - have applicationShouldOpenUntitledFile: return YES, allowing the framework to call newDocument at start up.

    - have applicationShouldHandleReopen:hasVisibleWindows: return NO, preventing it from calling newDocument when being reactivated via the dock.

As far as I can tell, the newDocument: message should only be sent only once and only if the application is opened without a document.

Is there a better way?

--
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

  • Follow-Ups:
    • Re: Starting window instead of a new untitled document?
      • From: PGM <email@hidden>
    • Re: Starting window instead of a new untitled document?
      • From: Michael Nickerson <email@hidden>
  • Prev by Date: Re: Tracking the mouse in a cell in a NSTableView
  • Next by Date: Aussie Mac Developers at WWDC?
  • Previous by thread: Moving NSRulerMarker and the document view
  • Next by thread: Re: Starting window instead of a new untitled document?
  • Index(es):
    • Date
    • Thread