Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a menu to the application in the dock?

When you right click on the application in the dock a context menu pops up. How can I add a menu item to this?

As for example with Safari you got New window in the context menu.

like image 631
Mark Avatar asked Nov 12 '15 21:11

Mark


1 Answers

Adding Static Menu Items With a Nib File

If your application needs to add static items to the application’s Dock tile’s menu, you can provide those items in a nib file. To do this, perform the following steps.

  1. Launch Interface Builder.
  2. Create a new nib file for your menu.
  3. Create a menu that includes the items you wish to add to the menu.
  4. Connect the dockMenu outlet of the file’s owner (which by default is NSApplication) to your menu.
  5. Add the nib name to the Info.plist, using the key AppleDockMenu. The nib name is specified without an extension.

Dynamically Adding Menu Items With the Application Delegate

An application can also provide items dynamically to your application’s Dock tile’s menu. To do this, your application’s delegate object provides a applicationDockMenu: method. This method returns a NSMenu object that provides all the custom menu items you wish to add to the menu. If you also provided a menu using a nib file (see Adding Static Menu Items With a Nib File), any menu returned by your delegate replaces the menu provided in the nib file.

(Source: https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/docktasks_cocoa/docktasks_cocoa.html#//apple_ref/doc/uid/TP30000986-CH3-SW7)

like image 67
Mark Avatar answered Sep 18 '22 02:09

Mark