Re: Drag and drop images to other application using NSFilesPromisePboardType
Re: Drag and drop images to other application using NSFilesPromisePboardType
- Subject: Re: Drag and drop images to other application using NSFilesPromisePboardType
- From: Dikshith Rai <email@hidden>
- Date: Mon, 9 Feb 2009 09:21:15 +0530
The reason I used only NSFilesPromisePboardType and not
NSFilenamesPboardType is:My app data is stored as a package.
Instead of extracting image from the package while I initiate
dragging, I do it when the destination asks for the data that is
promised to it. I personally feel NSFilesPromisePboardType will be
better if we drag multiple files + need to convert files to different
format that destination understands (In my case I create files with
different flavors ex: PNG,JPEG etc in temp location and then move it
to the destination.) Another advantage is, we can thread the creation
of different flavors.
Is there any way to transfer files to other apps using promised
pasteboard?
Sample code:
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL
*)dropDestination
{
Need to create Image in temp location and return the filename
array.
}
-(void)mouseDragged:(NSEvent*)event
{
NSPasteboard *pBoard =[NSPasteboard pasteboardWithName:
NSDragPboard];
[pBoard declareTypes:[NSArray
arrayWithObject:NSFilesPromisePboardType] owner:inView];
[pBoard setPropertyList:[NSArray arrayWithObject:KAppFileFormat]
forType:NSFilesPromisePboardType];
NSImage* imageToDrag= [[NSImage
alloc]initWithContentsOfFile:filePath];
NSPoint cPoint = [inView convertPoint:[event locationInWindow]
fromView:nil];
[inView dragImage:imageToDrag at:cPoint offset:NSMakeSize(0,0)
event:event pasteboard:pBoard source:inView slideBack:YES];
[imageToDrag release];
}
Regards,
Dikshith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden