Chapter 11: Taking Advantage of Services


In Mac OS X, certain applications are able to share useful functions with other applications. Apple refers to these functions as services (yes, with a small s), and they can save you time and effort. However, using them can seem a little tricky, because the way services are set up is somewhat counterintuitive until you know what you are doing. Here, our objective is to provide you with all the information you need to make use of services.

In this Chapter, we’ll take a look at the services available in Panther, and show you how to work with them. We spotlight the services provided by the Finder, Grab, Mail, Stickies, Speech, Summarize, and Text Edit. The other services available in Mac OS X are described at the end of the Chapter.

About Services

Services appear as an item in the Application menu of every Mac OS X compatible application. (The Application menu is the one that appears when you click on the application’s name in the menu bar. But you knew that.)

Choosing Services in Panther opens a submenu containing twelve items, none of which seem to work! But looks can be deceiving. Yes, at first glance, some of these items appear grayed-out, most of their commands are inaccessible, and their functions are not immediately apparent. How very mysterious! No wonder many move on and do not give the Services item a second thought.

The idea of services is to allow the applications and functions listed in the Services submenu to share their capabilities with other, compatible applications.

Here’s how it works: First, you select some data in an application, such as the string of text, “We’re coming to visit on Sunday.” Then you choose a command from the Services submenu, such as the Mail application’s Mail Text command. The command is executed on the selection, invoking Mail to create a new mail message with “We’re coming to visit on Sunday,” already placed in the message body. Very convenient!

For another example, in TextEdit you could invoke the Grab service’s Selection command to allow you to select a part of the screen to be inserted as an image in your TextEdit document.

Using services often seems as though Mac OS X invisibly copies your selected data from one application and pastes it into another; the latter application modifies the data and most often copies the result back into the original application before you know it.

The content you can use with services may include text, graphics, pictures, or movies.

There’s just one catch. It is important to note that services mainly work with applications and utilities written to run in Mac OS X’s Cocoa environment, such as Safari, Mail, TextEdit, and many of the other programs included with Mac OS X. There are also hundreds of third-party Cocoa applications and utilities.

Carbon applications cannot take advantage of services, except in the rare event they are written to support services. Most commercial Carbon apps such as the Microsoft Office applications, Adobe Photoshop and Illustrator, and QuarkXPress, do not currently support services. This may have something to do with the fact that it is reportedly quite difficult for developers to adapt a Carbon application to use services. Perhaps they will eventually get around to it... or perhaps not.

Now you can guess why the Services submenu items often have their commands dimmed; if you are looking at them from a typical Carbon application, none of them will work. But just one second now, I hear someone say. They will also appear unavailable from inside a Cocoa application! Correct, unless you first highlight the content you want the services to work on! Aha, a critical point; the not-quite-so-intuitive “secret” trick to taking advantage of services. Only Grab’s Services commands will be typically available before you select anything, because the entire screen is available to choose from. Also, a service will appear dimmed in the submenu if you have selected a type of content that the service does not work with.

You may find that after taking all this into account, the services command you want to use is still dimmed! The explanation: Some applications may not support every service. The application’s developer decides which services will be supported.

Here’s another critical point to keep in mind: services can’t create documents. They can only work with a document that is open in a services-compatible application. For example, the Grab utility can create documents, but the Grab service can only work with an open document in a Cocoa or services-compatible application. That is why the Grab service commands remain dimmed if you access them from the Finder; the Finder cannot create a document for the service to place results in.

Mac OS X services will (hopefully? should? with any luck?) become increasingly useful as more and more Cocoa applications are developed that can use them, and as Apple and third parties develop more programs which make services available.

Services are really the current continuation of Apple’s longtime dream of fostering communication and data exchange between individual applications. Some old-timers may still have enough functioning memory on their personal motherboards to recall the ancient notions called Publish and Subscribe. Another example would be Apple Events, still used in Mac OS X by those who make AppleScripts. Services are but a modest echo of such ambitious schemes; then again, services are more accessible and helpful.




Mac OS X Bible, Panther Edition
Mac OS X Bible, Panther Edition
ISBN: 0764543997
EAN: 2147483647
Year: 2003
Pages: 290

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net