On Jan 28, 2012, at 11:57 , Brad Stone wrote:

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

There's a couple of things I don't understand here.

If your document is a PNDocument, then you never add it to the menu via the 
super call, so of course there's no item there to have its name changed.

OTOH, unless your app has multiple doc classes AND the others use regular file 
names AND you're trying to mix regular file names and your special names on the 
same menu, then why are you bothering to leverage the document controller 
mechanism? Just opt out, and create your own Recent Items mechanism to use 
instead.

The problem with trying to integrate into any of document controller's standard 
behavior is that you might end up "fixing" the menu, but that won't solve 
anything for the dock menu, which was your original question.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to