Text-dragging tips

If you’ve used a Mac (or any GUI-based system) for any length of time, you’re probably quite aware of the concept of drag-and-drop—that is, click-and-hold on one object, then move it elsewhere, release the mouse, and drop the object. You’re probably also aware that, at least in OS X, you can drag and drop bits of text (i.e. snippets), say from an e-mail app into a word processing document (see this aside at the end for more info on how drag and drop works with text in the various types of OS X applications).

But you may not know that you can not only drag text between applications, but onto application icons in the Dock! Applications will handle the text in different ways. Also, not every application supports this feature; only some of them will accept text snippets dropped on their docked icons.

So how do you find out which applications support text snippets on their Dock icons? Simple—just drag a chunk of text, and move it across the Dock. If an application can accept the text, its icon will darken. If the icon doesn’t darken, you can try to force the application to accept the text by holding down Command and Option. Generally, though, this won’t lead to any interesting results.

Based on some of my experiments, as well as comments from macosxhints.com readers, here’s a list of applications that are known to do interesting and/or useful things when you drop a text snippet on their dock icons:

  • Acquisition: David Watanabe’s peer-to-peer file sharing application starts searching for files with names that match the words you dropped onto its icon.
  • Dictionary [10.4 only]: Tiger’s Dictionary displays the definition for the dropped word. If you drop a phrase, the first word in the phrase is defined.
  • Mail: The e-mail program opens a new message with the dropped text as the body.
  • Safari: The Web browser runs a Google search on the dropped text. Granted, this isn’t terribly useful if the text comes from an application that supports the Google contextual menu item. In these, of course, you can just control-click any word or phrase and choose Google Search from the pop-up menu. If the application supports the Services menu, you could also just hit Shift-Command-L. But if you’re in Microsoft Word or Excel or some other non-supported application, and you want to run a Google search on a text string, just drag and drop it to Safari’s Dock icon. This only seems to work this way for Safari. Other browsers either won’t accept the dropped text, or they don’t do anything with it.
  • Script Editor: Apple’s AppleScript editor opens a new script (and tries to compile it!) with the dropped text.
  • Skype: The voice-over-IP program (in other words, Internet telephone) dials the dropped number or the dropped nickname.
  • Stickies: Opens a new Sticky note with the dropped text as the contents.
  • Tex-Edit Plus: Trans-Tex Software’s scriptable, styled text editor appends dragged text to the topmost window you have open. If no windows are open, it opens a new window.
  • Text Edit: OS X’s text editor opens a new document that contains the dropped text.

Feel free to comment on any other apps you discover; I’m sure there are more!

Special Treatment of URLs

If the text snippet you drag is a URL (in other words, it starts with http:// , ftp:// , and so on), and you’re running OS X 10.4, you can drop the URL on any browser icon in the Dock. This is a handy feature if you’d like to open a URL in something other than your default browser. If you just click the link in its source (an e-mail message, for instance), it will open in your default browser. But by using drag and drop, you can open it with any browser with an icon in the Dock.

Aside on Dragging Text

Dragging and dropping text in OS X is functional, but somewhat confusing—you may think that text dragging only works in certain programs. This isn’t true; you can drag text in any OS X application. However, there are three different ways to do it, depending on how the program from which you’re doing the dragging was coded:

  • Carbon applications: Carbon is a “transitional” programming environment, designed to make it relatively simple for OS 9 applications to be made OS X native. A large percentage of the OS 9 programs that made the move to OS X (such as Microsoft’s Office, BareBones’ BBEdit, and so on) are Carbon applications. To drag text in a Carbon, it’s just as it was in OS 9. Simply highlight the text, then click-and-hold somewhere on the selection and start dragging.
  • Cocoa applications: Cocoa is Apple’s preferred environment for developing OS X applications. Nearly every Apple application is written in Cocoa, along with a growing list of third-party applications such as Panic’s Transmit and CocoaTech’s Path Finder. Dragging text in Cocoa applications seems quite broken at first, as if you try the Carbon method, nothing will happen—when you click-and-hold on the selection and move your mouse, you’ll find you’re simply starting a new selection. The answer is easy, if not obvious—you need to delay for about a second after you click-and-hold the selection, but before you start moving the mouse. You’ll then be able to drag the text, just as you can with Carbon applications.
  • Java applications: Java is yet another programming language, and its text dragging behavior is similar to Carbon—you can start dragging as soon as you click-and-hold on your selection. However, the results you get may be somewhat unexpected. In jEdit, a Java-based text editor that I use regularly, when I drag text out of its window and drop it elsewhere, the text disappears from my source document. I also see a window-sized generic rectangle when I start dragging; in Cocoa and Carbon apps, you’ll actually see the text you’re dragging around.
  • Classic: This is the old OS 9 environment, running within OS X. Unfortunately, you can’t drag and drop text from Classic applications—at least, based on my testing, I don’t think it’s possible (corrections welcomed!).

So if you’re trying to drag text in some application and it’s not working, the odds are good it’s probably a Cocoa application—just add the one-second delay before you try to drag, and all should be fine.

To comment on this article and other Macworld content, visit our Facebook page or our Twitter feed.
Shop Tech Products at Amazon