Re: Re: Drag to Finder and create a file
Re: Re: Drag to Finder and create a file
- Subject: Re: Re: Drag to Finder and create a file
- From: Tim Hewett <email@hidden>
- Date: Mon, 11 Apr 2005 16:24:01 +0100
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@hidden 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@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden