I'm trying to write some simple code to drag-and-drop the contents of a text file onto a window. With some help from an earlier post and an Apple example I've now got the basics of drag-and-drop up and running.
Unfortunately however, Apple's sample code deals only with images. Can anyone please tell me how I'd modify their "pasteboard" method (shown below) to send the contents of a simple 'dot.txt' file?
- (void)pasteboard:(NSPasteboard*)sender provideDataForType:(NSString*)type
{
//------------------------------------------------------
// method called by pasteboard to support promised drag types.
//--------------------------------------------------------
//sender has accepted the drag and now we need to send the data for the type we promised
if([type compare: NSTIFFPboardType]==NSOrderedSame)
{
//set data for TIFF type on the pasteboard as requested
[sender setData:[[self image] TIFFRepresentation] forType:NSTIFFPboardType];
}
else if([type compare: NSPDFPboardType]==NSOrderedSame)
{
[sender setData:[self dataWithPDFInsideRect:[self bounds]] forType:NSPDFPboardType];
}
}
Thanks :-)