Re: Open Recent menu - how to populate it?
Re: Open Recent menu - how to populate it?
- Subject: Re: Open Recent menu - how to populate it?
- From: Ali Ozer <email@hidden>
- Date: Mon, 20 Jul 2009 09:32:03 -0700
You can just go ahead and invoke -noteNewRecentDocumentURL: on
[NSDocumentController sharedDocumentController]. You don't have to
worry about explicitly creating or managing an NSDocumentController,
or do anything else that requires NSDocument.
TextEdit in Tiger did this (before it was converted to NSDocument).
Ali
On Jul 20, 2009, at 8:47 , Graham Cox wrote:
On 21/07/2009, at 1:36 AM, Alexander Bokovikov wrote:
Hi, All,
I'm writing a simple (in GUI) application, where NSDocument is not
used. I use NSOpenPanel to get a file name, then process file and
close it. There is no UI, related to file, where NSDocument could
help significantly. At least I believe so.
My problem is that Recent menu is empty, because in Cocoa (AFAIK)
it is maintained automatically by NSDocumentController, which is
absent in my app. So, my question is - how to create and update the
Open Recent menu "manually"? Where to store its items? How to
populate this submenu when my app is loaded?
Or should I use NSDocumentController anyway?
If your app isn't document based, it might complicate things too
much to have an NSDocumentController there (which is a global/
singleton).
Handling a recent items menu is pretty straightforward though - just
keep a list of the <n> most recent file paths you opened in an array
and use a menu delegate to update the menu from this. For extra
credit, check the validity/existence of the file when updating the
menu and remove bad ones and disambiguate duplicates. Someone might
have written a class to do this already.
The relevant functionality could go in the app's delegate or a
separate controller object with an outlet from the app's delegate.
--Graham
_______________________________________________
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