Last Revision: | Version 1.0, 2003-01-14 How to add a dynamic Dock menu to your Cocoa application |
Build Requirements: | |
Runtime Requirements: | Carbon Project Builder 1.1 or up, Mac OS X 10.1 or up |
This sample shows how to add a dock menu to your Cocoa application, so that clicking and holding on your application's dock icon displays a menu. It demonstrates this by scanning a folder of your choice (which you can choose from the "Preferences..." menu item) for pictures, displaying those pictures in the dock menu, and setting your desktop picture to the picture you choose from the menu. This sample does not show the most basic way of setting up a dock menu: creating your menu statically in Interface Builder, and wiring it up to the dockMenu outlet of the application. Instead, this sample shows how to dynamically create the dock menu on the fly and have many dock menu items hooked up to one action method. The code uses NSInvocations to work around a bug in Mac OS X 10.1.x that causes the sender for the NSMenuItem action method to always be the application, not the menu item. Requirements: Project Builder 1.1 or up, Mac OS X 10.1 or up Keywords: deskpictappdockmenu dock nsmenu dockling menu
Last updated: 2003-01-14