dragging images to the finder

  • All,

    I'm trying to get drag-and-drop to work, using the finder as a
    destination.  I can drag my files into mail using NSTIFFPboardType.
    My draggingSourceOperationMaskForLocal returns NSDragOperationEvery.
    But, when I drag my file onto a finder window, I get no icon at all...
    no little green plus indicating a copy.  My pasteboard:
    provideDataForType: is never called by the finder.  How the heck to I
    get the finder to accept a drop??

    Thanks,
    Eric
  • On Jan 11, 2009, at 9:48 PM, Eric Smith wrote:

    > I'm trying to get drag-and-drop to work, using the finder as a
    > destination.  I can drag my files into mail using NSTIFFPboardType.
    > My draggingSourceOperationMaskForLocal returns
    > NSDragOperationEvery.  But, when I drag my file onto a finder
    > window, I get no icon at all... no little green plus indicating a
    > copy.  My pasteboard: provideDataForType: is never called by the
    > finder.  How the heck to I get the finder to accept a drop??

    Assuming you are trying to create a picture file here, you have to use
    the pasteboard type "CorePasteboardFlavorType 0x6675726C" to get the
    Finder to accept the drag, and it must contain a file URL string
    pointing to the source image that you must write to the disk
    somewhere. Or you could do a file promise drag instead; that's a lot
    easier now than it used to be a while ago.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • On 12.01.2009, at 05:50, Nick Zitzmann wrote:

    > Assuming you are trying to create a picture file here, you have to use
    > the pasteboard type "CorePasteboardFlavorType 0x6675726C" to get the
    > Finder to accept the drag, and it must contain a file URL string
    > pointing to the source image that you must write to the disk
    > somewhere.

    You do not really have to create some data for this PB flavor type.
    It is much simpler.
    You do not even have know what such a flovor means (I guess it is
    part of AppleScript).

    Do this: somewhere tell the pasteBoard what types you use for dragging:

        NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSDragPboard];
        [pb declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType]
    owner:self];

    And eventually (I hope you know where the image is an the disc) you
    feed the pasteBoard with:

        BOOL rtn = [pb setPropertyList:[NSArray
    arrayWithObject:locationOfTheImage]
                              forType:NSFilenamesPboardType];

    (Yes, you need an NSArray of files! ).

    Now finally have a look at the dragPasteboard. It contains data for:

        NSFilenamesPboardType
        NeXT filename pasteboard type
        CorePasteboardFlavorType 0x6675726C ( 'furl' )
        Apple URL pasteboard type  (internal name for NSURLPboardType)
        CorePasteboardFlavorType 0x68667320  ( 'hfs ' )

    Do not underestimate the power of the PasteBoardServer!

        Godd luck,  Heinrich

    --
    Heinrich Giesen
    <giesenH...>