Version: 1.0

Posted: 2003-01-14

Build Requirements: N/A

Runtime Requirements: Carbon Project Builder 1.1 or up, Mac OS X 10.1 or up

View Source Code:

Download Sample (“DeskPictAppDockMenu.zip”, 49.3K)
Download Sample (“DeskPictAppDockMenu.dmg”, 103.6K)



Description

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

Document Revision History

Date Notes
2003-01-14How to add a dynamic Dock menu to your Cocoa application

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.