Re: Recently Opened in Doc
Re: Recently Opened in Doc
- Subject: Re: Recently Opened in Doc
- From: Brad Stone <email@hidden>
- Date: Sat, 28 Jan 2012 14:57:16 -0500
Thanks Quincey, I've already subclassed my NSDocumentController and I use noteNewRecentDocument to prevent my index file from showing up in the list. The code never gets past the continue call because every time this method is called the only menu item in [openRecentMenu itemArray] is "Clear Menu" (except when I quit out).
- (void)noteNewRecentDocument:(NSDocument *)aDocument {
if ([aDocument isKindOfClass:[PNDocument class]]) {
[super noteNewRecentDocument:aDocument];
}
NSMenu *fileMenu = [[[NSApp mainMenu] itemWithTitle:@"File"] submenu];
if (!fileMenu) {
return;
}
NSMenu *openRecentMenu = [[fileMenu itemWithTitle:@"Open Recent"] submenu];
if (!openRecentMenu) {
return;
}
for (NSMenuItem *openRecentMenuItem in [openRecentMenu itemArray]) {
NSString *title = [openRecentMenuItem title];
if ([title isEqualToString:@"Clear Menu"]) {
continue;
}
// code to change the menuItem title
}
}
On Jan 28, 2012, at 11:46 AM, Quincey Morris wrote:
> On Jan 28, 2012, at 08:19 , Brad Stone wrote:
>
>> I have a shoebox app like iPhoto where the actual filename is irrelevant to the user. I control the file name.
>>
>> What I'd like to do is just capture the menu items before they're displayed and change the menu titles into something relevant to the user. In the scheme of things it's a minor way to access the info in my app so if I could eliminate them that would be OK too. Changing the filename is not an option at this point.
>
> It seems to me you can subclass NSDocumentController, then override 'noteNewRecentDocument:' to do nothing. Presumably this will keep your filename off the "Open Recent" submenu, the "Recent Items" item on the Apple menu, and the dock menu. Then you should be able to delete the "Open Recent" item itself, and be left with no traces of recent items from your app.
>
> If you wanted to go the extra mile, you could create your own recent-items implementation, driven from your 'noteNewRecentDocument:' override, and using the 'applicationDockMenu:' application delegate method, with whatever document identifiers you want.
>
>
_______________________________________________
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