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: The Karl Adam <email@hidden>
- Date: Mon, 11 Apr 2005 13:24:46 -0400
There is plenty of documentation on HFS Promise drags, the problem
your running into is that Cocoa doesn't have the most complete
documentation for it.
The reason I didn't provide you with code in the first place was in
order to not deflect from the many discussions already on this topic
that I and other have provided info in.
So for posterity, here are the links to the info about this:
1) TechNote 1085(Using the Drag Manager to Interact with and
Manipulate File System Entities):
http://developer.apple.com/technotes/tn/tn1085.html
2) PasteBoard Reference:
http://developer.apple.com/documentation/Carbon/Reference/Pasteboard_Reference/index.html?http://developer.apple.com/documentation/Carbon/Reference/Pasteboard_Reference/paste_ref/chapter_1.2_section_2.html
3) Cocoa-dev discussions:
http://cocoa.mamasam.com/COCOADEV/2003/03/2/59716.php
http://lists.apple.com/archives/cocoa-dev/2004/Dec/msg01122.html
-Karl
On Apr 11, 2005 11:24 AM, Tim Hewett <email@hidden> wrote:
> 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
>
_______________________________________________
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