Control the 'text drag delay' time in Cocoa applications

Nov 22, '05 06:13:00AM

Contributed by: robg

I recently wrote a bit for Macworld, discussing the recent tip here on dragging text snippets to the Dock. In that writeup, I provided a brief overview of OS X's two modes of text dragging for those not yet familiar with the differeneces:

The delay-before-dragging bit makes many people believe that text drag is broken in Cocoa applications. Well, in the comments to my Macworld article, reader macmanga posted this very handy Terminal command:
defaults write -g NSDragAndDropTextDelay -int 100
This changes the delay-before-dragging for all Cocoa applications (the -g means "global domain," or all applications) from its default of 1000 (milliseconds, or one second) to 100, or one tenth of a second. Any currently-running applications must be quit and restarted to see the effect of the changes, but this definitely works.

Somewhat coincidentally, I was pointed to this thread on the Mac OS X Hints forum site, which contains a link this entry at Mac Geekery. That story, in turn, links to Apple's own Xcode Expert Preferences Notes as the source of the information. Noted in that document is this tidbit:

Setting this default to a non-positive value will disable drag-and-drop editing.
So I tried it, and it's true -- set the value to -100, and you won't be able to drag and drop text in any Cocoa application. Note also that you do not have to do this on a global basis. Instead, you could do something like this:
defaults write com.apple.TextEdit NSDragAndDropTextDelay -int -100
That would disable text dragging in TextEdit. Or if you want to leave it enabled in a certain application, but just want to make it much harder to do, try setting a large positive value:
defaults write com.apple.iPhoto NSDragAndDropTextDelay -int 3000
With that setting in place, you'd have to hold the mouse button for three seconds on any text in iPhoto before it was capable of being dragged.

Comments (13)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20051121074003638