Re: Drag to Finder and create a file
Re: Drag to Finder and create a file
- Subject: Re: Drag to Finder and create a file
- From: Lorenzo <email@hidden>
- Date: Mon, 11 Apr 2005 14:29:07 +0200
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
> From: Karl Hsu <email@hidden>
> Date: Sun, 10 Apr 2005 15:58:44 -0700
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: Drag to Finder and create a file
>
> Use promised drags, I think.
>
> Karl
>
> On Apr 10, 2005, at 11:46 AM, Lorenzo wrote:
>
>> Hi list,
>> I would like to drag an object from my app to the Finder and create my
>> own
>> file with my own fileName.
>> I can quite succeed when I declared the type NSTIFFPboardType in the
>> pasterboard, but when I declare my own type it doesn't work. I cannot
>> get
>> any file in the Finder. How to do that?
>>
>> myTypes = [NSArray arrayWithObjects:MyPboardType, nil];
>> [pboard declareTypes:myTypes owner:self];
>> [pboard setData:someData forType:MyPboardType];
>>
>>
>> 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
>>
> --
>
> Does proctor come from the same root word as proctal?
>
> Homepage:
> http://homepage.mac.com/khsu/index.html
>
_______________________________________________
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