• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Help with pasteboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with pasteboard


  • Subject: Re: Help with pasteboard
  • From: Brian Webster <email@hidden>
  • Date: Thu, 18 Oct 2001 16:31:27 -0500

On Thursday, October 18, 2001, at 03:08 PM, Charles Srstka wrote:

On Thursday, October 18, 2001, at 02:03 PM, Brian Webster wrote:

OK, it appears that the Finder "prefers" to take the string rather than the file if both are offered. It appears to really be an issue with the Finder, not with your code specifically. When you drop your data onto the Finder, does it correctly create a text clipping file? Have you tried only offering the file contents type? Does it create a plain text file then?

Hmm, I just tried doing that, and the drag operation was aborted each time. When I dragged an item to the Finder, it would be flung right back into my outline view. I used the following line to declare the file type:

[pboard declareTypes:[NSArray arrayWithObject:NSFileContentsPboardType] owner:self];

and the Finder would not accept a drag from my app. Even if I immediately wrote the wrapper to the pasteboard right in the writeItems: toPasteboard: method, the Finder would have none of it. Apparently the Finder doesn't want to receive NSFileContentsPboardType. Odd.

OK, here's what I've discovered after a little investigation. The problem is that we're dragging between a Cocoa app and a Carbon app. While a handful of drag flavors are translated by the unified dragging mechanism, NSFileContentsPboardType (or flavorTypePromiseHFS in Carbon-speak) does not appear to be one of them.

I ran a couple tests using a nice little app called Dragster, which will accept any drag-and-drop input into a window and give you info on what drag flavors are available, what the data is for each flavor, etc. I tried dragging some items from various Cocoa apps to see what showed up in the translation over to the Carbon drag manager.

Text dragged fine, as do existing files (NSFilenamesPboardType) dragged from Project Builder or document proxy icons. However, file contents did not show up at all when dragged over to the Dragster window. So, it appears NSFileContentsPboardType does not get translated over to flavorTypePromiseHFS. I would consider this to be a bug, or at the very least a very important missing feature. I confirmed that it's not a Finder-specific bug by being able to drag text from IE to the Finder, and it created a plain text file just fine.

As for a workaround, I guess the only way to do it now is to instead declare the NSFilenamesPboardType, write the data to a temporary file (the NSTemporaryDirectory() function comes in handy here) and write its path to the pasteboard. When the drop operation occurs, the Finder should move/copy/link (depending on modifier keys) the file to the drop destination. It's kinda ugly, but it should work.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster


  • Follow-Ups:
    • Re: Help with pasteboard
      • From: Charles Srstka <email@hidden>
References: 
 >Re: Help with pasteboard (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Adding some polar coordinate capabilities to NSBezierPath.
  • Next by Date: Re: [Q]: Object ownership, undos, tableview, etc.
  • Previous by thread: Re: Help with pasteboard
  • Next by thread: Re: Help with pasteboard
  • Index(es):
    • Date
    • Thread