• 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: Open Recent Menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open Recent Menu


  • Subject: Re: Open Recent Menu
  • From: "ronald b. kopelman" <email@hidden>
  • Date: Tue, 14 Aug 2007 09:17:56 -0400

On Aug 14, 2007, at 8:10 AM, Jeff Bland wrote:

I'm trying to create a open recent menu in an application. The application
is not currently document based, because I've had no reason to make it
document based. It's also not really a document based application - it opens
one file at once, in one window, and doesn't do any editing or saving to the
files it opens.

What I would do is save the recent document file names (entire path) to an external file; possibly a plist file. This file can be updated every time you open a new file. The code to save and retrieve the file names should not be too hard. I would then set up a "Recent Document" menu item in the File menu. This can be done easily in Interface Builder (or by code). In your application controller, add the NSMenu delegate method (void)menuNeedsUpdate:(NSMenu *)menu This is the place to put your code for retrieving the file names & populating the menu. It gets called each time the menu is about to be opened. I would strongly suggest clearing out the menu 1st & then repopulating it, but this may not be necessary in your case. Remember to name the menu item in your application controller's .h file & make your application controller the delegate of the menu item by dragging the .h file into Interface Builder & hooking it up. The format in which I would save the data is as an NSDictionary. Each key is the file name that you would like to appear in the menu and the data is its URL or whatever they call it. However, you could just store it as an array if the name is not that important.


In my application, I do this to repopulate a menu from a matrix of place names kept in the user prefs that the user is allowed to change. It seems to work just fine. However, I am a newbe to all of this (& the list) so there may be a much better way to do it.

ronald b. kopelman
email@hidden


_______________________________________________

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


  • Follow-Ups:
    • Re: Open Recent Menu
      • From: "Jeff Bland" <email@hidden>
  • Prev by Date: Re: Newly inserted objects not retrieved with executeFetchRequest...
  • Next by Date: Re: Overlay over webView
  • Previous by thread: Open Recent Menu
  • Next by thread: Re: Open Recent Menu
  • Index(es):
    • Date
    • Thread