Drag and Drop a File... help!!
Drag and Drop a File... help!!
- Subject: Drag and Drop a File... help!!
- From: "Stephen C. Jensen" <email@hidden>
- Date: Sat, 7 Dec 2002 09:53:47 -0800
HELP!
I have written a small Cocoa app that access our local oracle phone
database and displays lists of people. With 10.2, I've used the
Address Book APIs to hook the two together, which works really well.
My latest change was to add the capability to save a person as a
vCard... works great. Now, I want to add the ability to drag a person
into the finder (or Palm Desktop, or Address Book, or ...) and have
the data transferred as a vCard (similar to how address book works).
I can't figure this out for the life of me! I have drag and drop
enabled, and can drag a text representation out to other programs as
NSStringPboardType. What do I need to add to make the vCards work?
I did try adding NSFilenamesPboardType , using the following in my
"myTableView" class:
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard
types:(NSArray *)types
{
int index = [self selectedRow];
Employees *anEmployee; // my Employees class
if(index >= 0) { // If a row is selected...
anEmployee = [ thePhoneController GetEmployeeAtRow: index];
// Get the employee at the selected row
// set up both the Filenames and String Pboard Types
[pboard declareTypes:[NSArray arrayWithObjects:
NSFilenamesPboardType, NSStringPboardType, nil] owner:self];
// Put some test data into the NSFilenamesPboardType
[pboard setPropertyList:[NSArray
arrayWithObject:@"/tmp/test.txt"] forType:NSFilenamesPboardType];
// Put a nice text synopsis of the Employee in as the
NSStringPboardType
[pboard setString: [anEmployee getAllInfo] forType:
NSStringPboardType];
return YES;
} else {
return NO;
}
}
Although this compiles, I still get a text clipping when I drag to
the finder. Where do I actually provide the file contents? Where does
the Finder tell me where it wants the file located? Help!!!
Thanks!
--
Stephen C. Jensen
Flight Systems Engineering Branch/Code RF
Dryden Flight Research Center
<
mailto:email@hidden>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.