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

1

8

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.

Thirst answered 12/11, 2015 at 21:18 Comment(1)
Check out the Dock Tile Programming GuideCollinear
T
11

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)

Thirst answered 13/11, 2015 at 7:55 Comment(1)
Is there any documentation/tutorial on how to add a dynamic menu while the application is shutdown. Similar to the jump list menu, Xcode has to projects previously opened?Closemouthed

© 2022 - 2024 — McMap. All rights reserved.