My question is quite simple :
To use a custom menu for the apps icon on the dock, - (NSMenu*) applicationDockMenu: (id) sender; of the NSApplicationDelegate has to return the menu that the dock will display.
Using setImage on a NSMenuItem, you can normaly add icons to the menu. They show up on the normal menu, but not on in contextual menu of the app’s dock icon.
Then how did Apple manage QuickTime, XCode, Preview to show icons in the list of recent opened files accessible in their dock contextual menu ?
Thx.
The recent files list is actually part of the standard Dock icon menu. To use it in your app, you should build an
NSDocument-based application. By usingNSDocument, you will get the recent files menu/behaviour for free.If your application cannot be based on
NSDocument, you can instruct Cocoa to maintain a recent documents list based on URLs:Note that currently,
-noteNewRecentDocumentURL:only supportsfile://URLs (which you can create from a path with+[NSURL fileURLWithPath:].) In the future, its behaviour will presumably change to allow URLs with other schemes.