Drag&Drop NSTextView not working?
Drag&Drop NSTextView not working?
- Subject: Drag&Drop NSTextView not working?
- From: <email@hidden>
- Date: Thu, 10 Mar 2005 6:59:42 +0000
I know, I know, subjects like "not working" are taboo here, but I can't think of any other way to put it. I'm trying to implement my NSTextView subclass to allow the dropping of files from the Finder on it, and I've added all the code from the Apple docs and various examples on the web. But when I run my app, I try to drag a single file from the Finder over my NSTextView subclass, and it just plain doesn't take the drop. Here's the relevant code:
First, I've overridden - (void)acceptableDragTypes to add NSFilenamesPboardType to the acceptableDragTypes array. I also had this set in the init method with registerForDraggedTypes, still didn't work.
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard* pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ([[pboard types] containsObject:NSFilenamesPboardType])
{
if (sourceDragMask & NSDragOperationLink)
{
return NSDragOperationLink;
}
else if (sourceDragMask & NSDragOperationCopy)
{
return NSDragOperationCopy;
}
}
return NSDragOperationNone;
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard* pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ([[pboard types] containsObject:NSFilenamesPboardType])
{
NSArray* array = [pboard propertyListForType:NSFilenamesPboardType];
[self setFiles:array]; // sets the array to an ivar
}
return YES;
}
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
[self writeFilesToView]; // simply writes the filenames to the textview
}
Am I missing something? Thanks.
James
_______________________________________________
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