Skip navigation.
 
mlRe: Re: Drag to Finder and create a file
FROM : Tim Hewett
DATE : Mon Apr 11 17:24:01 2005

Lorenzo,

See here for Apple's documentation:

http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/
Tasks/DraggingFiles.html#//apple_ref/doc/uid/20001288/102943

It's fiddly and convoluted, but once you've got it working you can 
forget
about it.

Tim.


On 11 Apr 2005, at 15:38, <email_removed> wrote:

> Yes, thank you,
> but how to implement "promised drags" properly?
> I am getting crazy with that. There is no documentation about it.
> The Cocoa Drag and Drop methods are something opaque so the only way 
> to make
> it work is to understand the mechanism. To know how to use any single 
> API.
> Instead, nothing, Apple think that we developers have magic powers...
>
> Looking at some code I have found on the web it seems that I need to 
> add
>
>    dragPromisedFilesOfTypes:
>
> within the
>
>    - (BOOL)outlineView:(NSOutlineView*)olv writeItems:(NSArray*)items
>    toPasteboard:(NSPasteboard*)pboard
>
> So I did that and now the only place I can write the item data to a 
> file in
> the Finder, seems to be within
>
> -(NSArray*)namesOfPromisedFilesDroppedAtDestination:
> (NSURL*)dropDestination
> {
>    // ...
>    NSData      *itemData = [selectedItem GetItemData];
>    NSString    *filename = [[dropDestination path]
>                stringByAppendingPathComponent:[selectedItem 
> objectName]];
>
>    [itemData writeToFile:filename atomically:YES];
>
>    return [NSArray arrayWithObject:[selectedItem objectName]];
> }
>
>
> Even if this seems to be the only place where I can get the 
> destination URL,
> it sounds so strange that I have to write the item-file within an API
> returning namesOfPromisedFiles.... Or is it right?
> Also, when I drag an item from the outlineView, if the destination is 
> the
> outlineView itself, I don't have to create a file. I have just to move 
> the
> item within the outline view. BUT, since I call 
> dragPromisedFilesOfTypes:
> (see here above) to let the user drag the item to the Finder too, now 
> every
> time I start a drag I see a white file icon and I cannot drag the item
> within the outline view anymore. I can only drag it to the Finder.
> Moreover, the API draggingSourceOperationMaskForLocal doesn't give me 
> any
> info about the draggingPasteboard, so even if I override it, I cannot 
> change
> the behaviour of the drag on the fly depending on the object is 
> overriding
> the Finder or the object is overriding the outline view itself. 
> Amazing!
>
> I am sure I am missing something important. But what?
> Why does this simple task is made so complicated?
> Why there is not documentation nor sample code in the Developer/Example
> folder?
>
>
>
> Best Regards
> --
> Lorenzo
> email: <email_removed>

Related mailsAuthorDate
mlDrag to Finder and create a file Lorenzo Apr 10, 20:46
mlRe: Drag to Finder and create a file Serge Meynard Apr 11, 00:49
mlRe: Drag to Finder and create a file The Karl Adam Apr 11, 03:59
mlRe: Drag to Finder and create a file Lorenzo Apr 11, 14:29
mlRe: Re: Drag to Finder and create a file Tim Hewett Apr 11, 17:24
mlRe: Drag to Finder and create a file Lorenzo Apr 11, 18:43
mlRe: Re: Drag to Finder and create a file The Karl Adam Apr 11, 19:24
mlRe: Drag to Finder and create a file Serge Meynard Apr 11, 19:27