Applications that provide services are installed in the Applications
and Library/Services
folders in any of the four file-system domains—System, Network, Local, and User. (See “File-System Domains” in System Overview for details on file-system domains.) The applications’ information property lists declare the services the applications provide (see “Services Properties”). Mac OS X collects the property list information and uses it to populate the items in the Services menu based on the particular data types supported by each application.
The Services menu is included in the default nib file created by Xcode and Interface Builder for Cocoa applications. If the application’s menu is instead created programmatically, you need to designate a Services menu using the NSApplication method setServicesMenu:
. If an application registers for services (see “Using Services”), the appropriate items are automatically available in the Services menu.
The items in the Services menu can be commands or submenus that contain commands. If an application offers only one service, just the service (stated as a command) is listed in the Services menu. For example, the Stickies application offers only one service—making a new Sticky note—so only the command Make Sticky is listed in the Services menu.
If an application offers more than one service, the application’s name usually appears in the Services menu, and the services offered by the application appear in a submenu. For example, the Grab application offers three services: taking a screen shot of the entire screen, taking a screen shot of a selected part of the screen, and taking a screen shot of the entire screen after a set amount of time. As you can see in Figure 4, Grab is an item in the Services menu that has its own submenu listing the commands that invoke Grab’s three services: Screen, Selection, and Timed Screen.
The Services menu is populated when the application launches, but its items are not enabled until the user chooses Services from the application menu. Choosing Services causes the current responder chain to be searched for objects that can provide or receive data of the types used by each service listed in the Services menu. If an object is found that can use a given service, the service’s menu item is enabled. Menu items for which no suitable object is found are dimmed, unavailable for the user.
© 2003, 2002 Apple Computer, Inc. All Rights Reserved. (Last updated: 2002-11-12)