drag-n-drop
drag-n-drop
- Subject: drag-n-drop
- From: Chase <email@hidden>
- Date: Thu, 16 Jun 2005 01:38:33 -0500
i got this code from apple's docs. still, dragging a PNG file (or any
file for that matter) from the finder into my nswindow subclass does
nothing.
what am i missing here? ultimately i just want to drag png files onto
the window.
in my init() override, i've got:
[self registerForDraggedTypes:[NSArray
arrayWithObjects:NSFilenamesPboardType, nil]];
plus these two methods:
- (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)performDragOperation:(id <NSDraggingInfo>)sender {
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
NSArray *files = [pboard
propertyListForType:NSFilenamesPboardType];
int numberOfFiles = [files count];
if (numberOfFiles>0) {
NSLog(@"%d file(s) : %s", numberOfFiles, [files objectAtIndex:0]);
}
}
return YES;
}
- chase
_______________________________________________
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