5.9. The Cocoa Difference

 < Day Day Up > 

Here are some of the advantages Cocoa programs offer. It's worth readingnot to make you drool about a future when all Mac programs will fall into this category, but to help clear up any confusion you may have about why certain features seem to be present only occasionally.


Note: The following features appear in almost all Cocoa programs. That's not to say that you'll never see these features in Carbonized programs; the occasional Carbon program may offer one of these features or another. That's because programmers have to do quite a bit of work to bring them into Carbon applicationsand almost none to include them in Cocoa ones.

5.9.1. The Font Panel

The Mac has always been the designer's preferred computer, and Mac OS X only strengthens its position. For one thing, Mac OS X comes with about 100 absolutely beautiful fonts that Apple licensed from commercial type companiesabout $1,000 worth, according to Apple.

When you use a Carbon program, you usually access these fonts the same way as always: using a Font menu. But when you use a Cocoa program, you get the Font panel, which makes it far easier to organize, search, and use your font collection. Chapter 14 describes fonts, and the Font panel, in more detail.

5.9.2. Title Bar Tricks

You may remember from Chapter 2 that the title bar of every Finder window harbors a secret pop-up menu. When you -click it, you're shown a little folder ladder that delineates your current position in your folder hierarchy. You may also remember that the tiny icon just to the left of the window's name is actually a handle that you can drag to move a folder into a different window.

In Cocoa programs, you get the same features in document windows , as shown back in Figure 2-5 (Section 2.4.2). (This feature is available in many Carbonized programs, but it isn't a sure thing.) By dragging the tiny document icon next to the document's name, you can perform these two interesting stunts:

  • Drag to the desktop . By dragging this icon to the desktop, or onto a folder or disk icon, you create an instant alias of the document you're working on. This is a useful feature when, for example, you're about to knock off for the night, and you want easy access to whatever you've been working on when you return the next day.

  • Drag to the Dock . By dragging this title-bar icon onto the Dock icon of an appropriate program, you open your document in that other program. For example, if you're in TextEdit working on a memo, and you decide that you'll need the full strength of Microsoft Word to dress it up, you can drag its title-bar icon directly onto the Word icon in the Dock. Word then launches and opens up the TextEdit document, ready for editing.

Unfortunately , you can't drag an open document directly into the Trasha technique that could come in handy for writers who struggle with first drafts.

5.9.3. Services

Apple has always dreamed of a software architecture that would let you mix and match features from different programsusing the AppleWorks spell checker in Microsoft Word, the drawing tools of PowerPoint in your email program, and so on. (Remember Apple's OpenDoc software project? Neither does anybody else.)

In Mac OS X, Apple's dream has finally become a reality. Nestled in the Application menu of almost every Mac OS X program is a command called Services. Its submenu lists several functions that technically belong to other programs, as described below.

Unfortunately, these commands are dimmed when you use most Carbonized programs (like AppleWorks, Photoshop, and Microsoft Office). They become available only when you use Cocoa programs like iChat, TextEdit, Mail, OmniWeband the Finder. (Yes, the Finder is a Carbon program. But remember that programmers can add Cocoa features to their older, Carbonized programs; it just takes a lot of work.)

Here's a summary of what they do.


Note: Not all of these Services work in all programseven Cocoa programs. (iPhoto doesn't, for example.) Implementing them is left to programmers' discretion. A little unpredictability along these lines is par for the course.
5.9.3.1. ChineseTextConverter

Talk about obscure: This utility, new in Tiger, converts selected text that you've written in Chinese using its Simplified text system into the Chinese Traditional text systemor vice-versa. Let the celebration begin!

5.9.3.2. Disk Utility

Here's another new Service that everyday Mac fans haven't exactly been clamoring for. This one lets software programmers and system administrators check to make sure that the disk image files they've created (Section 5.10.2) haven't been altered without even having to double-click and "mount" the disk image.

5.9.3.3. Finder

The three commands listed in this submenu work in only one situation: When you've highlighted some text that precisely matches the name and folder path of any icon, such as ~/ Documents/Marge.jpg . (Details on path notation on Section 1.2.2.)

At that point, you can choose any of these commands from the Services Finder submenu:

  • Open . Opens the icon. This command, in effect, lets you open any file on your hard drive, from within any Cocoa program, without having to switch to the Finder. For example, you could keep a list of your favorite files and programs in a TextEdit document, ready for opening without having to leave the program.

  • Reveal . Takes you to the Finder, where the specified icon is highlighted and its enclosing folder opened into a window.

  • Show Info . Switches to the Finder, where the Get Info window for the specified file opens, for your inspection pleasure .

If what you've highlighted isn't the name and path of a document, you'll get only an error message.

5.9.3.4. Font Book

Font Book, as you can read in Chapter 14, is a font-managing program. Among other talents, it can clump your fonts into Collections ( subsets of your choice) or Libraries (collections of Collections).

These Service commands generate a whole collection or library of fonts contained in one document (whatever's on the screen at the time). Begin by highlighting the text that uses the fonts (usually you'll want the whole document). Then choose Services Font Book Create Collection [or Font Library] From Text. In a moment, youll see that the Font Book program has opened automatically, and there's a new collection or library in the Collection list at the left side, ready for you to rename.

The payoff comes when you want to submit the document to, for example, a graphics shop for professional printing, or to someone who'll be editing your work on a different computer. Font Book can easily export a collection of fonts (File Export Collection) that you can send out with the document itself, so the recipients will enjoy the same delightful design you did.

5.9.3.5. Grab

Grab is a screen-capture program in your Applications Utilities folder. You use it to turn what you see onscreen into graphics files. Its especially handy when writing computer books or training manuals.

The Grab service, in theory, lets you take your software snapshot from within any Cocoa application, without having to go find and launch Grab separately; unfortunately, it's available only in programs that can accept pasted graphics. You'll find details on Grab's submenu commands (Screen, Selection, Timed Screen) on Section 10.26.10.3.

5.9.3.6. Import Image

This option lets you import a digital photo from a scanner or digital camera, if one is attached and ready to roll. Like Grab, it works only in Cocoa programs that accept pasted graphics, and like Image Capture (on which it's based), it can operate only Web-cammable digital cameras and compatible scanners (see Section 10.12.5).

5.9.3.7. Look Up in Dictionary

Here's yet another way to access the new Tiger Dictionary program. Highlight a word, choose this command, and presto: the Dictionary program opens automatically and proudly presents a definition for your enlightenment. (There are easier, more universal ways to look up words in Tiger, as described on Section 10.7.)

5.9.3.8. Mail

This handy command springs to life only after you've highlighted some text in a Cocoa programor a file in the Finder.

  • Send Selection . In one step, the Mail Text command launches the Mail program and pastes the highlighted text into the body of a new, outgoing email message. You're saved the trouble of copying, launching Mail, creating a new message, and pasting. You might use this feature when, for example, you find something interesting on a Web page, and you'd like to email it to someone.

  • Send To . This command is useful only if you've highlighted an email address in a text document. This command, too, switches to Mail and creates a new, outgoing messagebut this time, Mac OS X pastes the text you've highlighted into the "To:" field.

5.9.3.9. Make New Sticky Note

This command copies whatever text you've got highlighted, switches to your Stickies program (Section 10.23.1), creates a new sticky note, and pastes your selected material in it. If you're the kind of person who keeps your lifelists, passwords, favorite URLs, to-do list, notes, and so onin Stickies, this one can save you considerable hassle. No wonder Apple endowed it with its own keyboard shortcut: Shift- -Y.

5.9.3.10. Open URL

When you highlight a Web address in any program, choosing this command fires up your Web browser and takes you to the indicated page.

5.9.3.11. Script Editor

For AppleScript fans only (Chapter 8).

  • Get Result of AppleScript . This command processes whatever text you've highlighted as an AppleScriptand then replaces the selected text by the result of your script.

  • Make New AppleScript . This item works just like Make New Sticky Note, except that it copies your text into Script Editor rather than Stickies.

  • Run as AppleScript . This one runs a selected blot of text as if it were an AppleScript, much like Get Result of AppleScript. The only difference: It doesn't replace the selected text with the result of your script.

None of these Script Editor services do any error checking. If you forget a quotation mark in your script, it simply won't run.


Tip: If you know how to use the do shell script command, you can run Unix commands directly from your service-enabled programs (see Chapter 16).
5.9.3.12. Search with Google

Never let it be said that inspiration is dead in the post-tech-bubble era. This unassuming command adds a powerful research assistant to every program where you can type. Highlight a phrase Picasso, electric curtains, Yankees game and hit this command. In seconds, you're online, in your Web browser, facing a list of Web pages from a Google search for that topic. It's a dictionary, thesaurus, news service, and stock ticker all in one.

The gang at Apple loves this one, too. They blessed it with its own keyboard shortcut: Shift- -L (for look up).

5.9.3.13. Send File to Bluetooth Device

Bluetooth is a short-range, wireless, cable- elimination technology. It's great for tossing files between two Macs (or a Mac and a Windows laptop, for that matter), on the fly, on a plane, without any cables or setup. (Your Mac must have a Bluetooth transmitter, of course. All current PowerBooks do, for example.)

If you've highlighted the path of a file (see the tip below), this command grabs the file and hands it off to Bluetooth File Exchange, which begins the process of transmitting it to a nearby Bluetooth computer. (Section 7.2.5 describes this ritual .)

5.9.3.14. Speech

As detailed in Chapter 15, Mac OS X doesn't just display text onscreenit can actually read it out loud.

  • Start Speaking Text . Start by highlighting some text in a Cocoa program. Then choose this command, and presto: The Mac actually reads the text out loud, using the character voice you've chosen in System Preferences (Section 15.4.2.6).

  • Stop Speaking . This command makes the Mac shut up.


Tip: If you highlight an icon in the Finder, the Start Speaking Text command reads its path to you. For example, for a Flowers.tif file in your Home Pictures folder, whose path is Users/chris/Pictures/Flowers.tiff , the Mac says, "Users, Chris, Pictures, Flowers dot tiff."
5.9.3.15. Spotlight

As you know from Chapter 3, Spotlight is always at your command, ready to find files, folders, or programs at the touch of a key. But the -Space bar trick requires you to type in a search phrase. This Service command (and its keystroke, Shift- -F), on the other hand, triggers a Spotlight search for a word or phrase that's already typedone that you've highlighted in whatever document is before you.

5.9.3.16. Summarize

Talk about intriguing: When you choose this command after highlighting some text, the Mac analyzes the sentences you've highlighted and, after a moment, launches Summary Service. This little program, which you probably never even knew you had, displays a greatly shortened version of the original text. Figure 5-16 offers details.


Tip: To save the summarized document as a TextEdit document, choose File Save As.
TextEdit Open Selected File to find and open that document in TextEdit. (If what youve highlighted isn't the name of a document, you'll get only an error message.)

Figure 5-16. Use the Summarize command to create a one-paragraph summary (bottom) of a longer passage (top).
Once the summary appears in the Summary Service program, you can make it more or less concise by dragging the Summary Size slider. You can also ask it to display the most statistically relevant paragraphs instead of sentences, just by clicking the appropriate radio button at the lower left.
(Note: Bear in mind that Summary Service doesn't do any creative rewriting; even Mac OS X can't come up with something coherent if the original wasn't. Instead, Summary Service chooses the most statistically significant sentences to include in the summary.)


Although these are the commands that come built into a fresh installation of Mac OS X, that's not the end of the versatility. The real beauty of Services is that as new, clever applications come along, they can add their own commands to this menu for your data-manipulation pleasure.


Tip: InstantLinks, a piece of $5 shareware from Subsume Technologies, offers a useful look ahead to the future of Services. It adds commands to your Services menu that send your highlighted text to various services on the Web.For example, you can choose Dictionary Lookup (looks up the selected text in an online dictionary), Map Location (looks up the selected address at MapQuest.comgreat when somebody emails you an invitation ), Open URL, Search Web, and Thesaurus Lookup. You can download it from the "Missing CD" page of www.missingmanuals.com.

5.9.4. Toolbar Tricks

The toolbar is an increasingly common sight at the top of modern application windows. In any thoughtfully written program, the Customize Toolbar command lets you determine how you want this toolbar to show upwith icons, as icons with text labels beneath them, with text labels alone to save window space, and so on.

But in many Cocoa programsincluding OmniWeb, Mail, Address Book, and Xcodethere's a much faster way to switch among these toolbar styles: Just -click the white button shown in Figure 5-17.

Figure 5-17. By -clicking this button repeatedly, you can cycle among various toolbar styles. In Mail, for example, you can cycle between six different toolbar styles: with icons and labels (large and small); with icons only (large and small); and with text labels only (large and small).


5.9.5. Secret Keyboard Shortcuts

For the most part, it's possible to ignore the Unix that beats within the heart of Mac OS X. But every now and then, a refreshing reminder pokes its head up through the fields of brushed metaland here's one of them.

Although you'll never see it mentioned in the user manuals for Cocoa applications (if there even were such things as user manuals anymore), most of them respond to certain keystrokes left over from the NeXT operating system (Mac OS X's ancestor ).

If you're a card-carrying number of KIAFTMA (the Keyboard Is Always Faster Than the Mouse Association), you'll love these additional keyboard navigation strokes:

  • Control-A . Moves your insertion point to the beginning of the paragraph. ( Mnemonic : A = beginning of the Alphabet.)

  • Control-E . Deposits your insertion point at the end of the paragraph. ( Mnemonic : E = End.)

  • Control-D . Forward delete (deletes the letter to the right of the insertion point).

  • Control-K . Instantly deletes all text from the insertion point to the right end of the line. ( Mnemonic : K = Kills the rest of the line.)

  • Control-O . Inserts a paragraph break, much like Return, but leaves the insertion point where it was, above the break. This is the ideal trick for breaking a paragraph in half when you've just thought of a better ending for the first part.

  • Control-T . Moves the insertion point one letter to the rightand along with it, drags whichever letter was to its left. ( Mnemonic : T = Transpose letters .)

  • Option-Delete . Deletes the entire word to the left of the insertion point. When you're typing along in a hurry, and you discover that you've just made a typo, this is the keystroke you want. It's much faster to nuke the previous word and retype it than to fiddle around with the mouse and the insertion point just to fix one letter.

Four additional keystrokes duplicate the functions of the arrow keys. Still, as long as you've got your pinky on that Control key

  • Control-B, Control-F . Moves the insertion point one character to the left or right, just like the left and right arrow keys. ( Mnemonic : Back, Forward).

  • Control-N, Control-P . Moves the insertion point one row down or up, like the down and up arrow keys. ( Mnemonic : Next, Previous).

5.9.6. Cool Text-Selection Tricks

By holding down certain keys while dragging through text in a Cocoa program, you gain some wild and wacky text-selection powers. (You'll find them especially useful in, for example, TextEdit and Pages.)

For example:

  • Highlight only one column out of several by Option-dragging. Instead of highlighting all of the text, margin to margin, you get only the text that's within your selection rectangle. This trick is especially handy in Preview, when you want to copy only one portion of a PDF document that has a columnar layout.

  • Highlight several passages simultaneously by -dragging. Each time you -drag, you highlight another block of text, even though the earlier blocks are still selected (see Figure 5-18).


Tip: In most Cocoa programs, you can combine these two tricks. That is, you can select multiple, arbitrary (not full-page-width) blocks of text by pressing both Option and as you drag.

5.9.7. Background Window Control

As hinted in Chapter 1, the key unlocks a slick trick in Cocoa programs: It lets you operate the buttons and controls of an inactive, background window without bringing it to the front. You can operate a background window's resize box, buttons , pop-up menus , and scroll bars, all while another window is in front of it. In fact, you can even drag through text in a background windowand then drag-and-drop it into the foreground window. (Freaky!)

In every case, the secret is simply to keep pressed as you click or drag.

Figure 5-18. The beauty of being able to select multiple blobs of text is that you can format all of them at once. Then you can format it all simultaneously (making it bold, for example) with one click. You can also copy the selected portions; when you paste into a different document, you get a tidy excerpt containing only the parts you wanted, all run together.


 < Day Day Up > 


Mac OS X. The Missing Manual
Mac OS X Snow Leopard: The Missing Manual (Missing Manuals)
ISBN: 0596153287
EAN: 2147483647
Year: 2005
Pages: 506
Authors: David Pogue

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