Re: Open Recent Menu
Re: Open Recent Menu
- Subject: Re: Open Recent Menu
- From: "Jeff Bland" <email@hidden>
- Date: Tue, 14 Aug 2007 13:48:05 -0600
On 8/14/07, ronald b. kopelman <email@hidden> wrote:
>
> 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.
Thanks Ronald,
Actually the NSDocument controller is doing the saving for me so I do'nt
have to manage a file myself. Your plan for repopulating the menu is good -
and I will go about that if I can't find a way to have the system do it. I
believe the system can do it (even in non-document based applications)
because I don't see any code in TextEdit that manually inserts items in the
open recent menu.
Also if I can figure out how to get the system to manage my open recent menu
I get standard behavior, and nifty things like:
"Thanks to changes in Cocoa, TextEdit's recent documents menu will now
correctly track documents whose volumes or enclosing folders have been
renamed."
Although I'm not sure if that's referring to the Recent Items menu under the
apple menu or the open recent menu under the file menu.
_______________________________________________
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