CocoaDev

Edit AllPages

Here’s a simple drag and drop example for filenames dragged from the finder –zootbobbalu

Header

#import <AppKit/AppKit.h>

@interface TestDragAndDropView : NSView { NSColor *backgroundColor, *blueColor, *greenColor; }

@end

Source

#import “TestDragAndDropView.h”

@implementation TestDragAndDropView

-(void)draggingExited:(id )sender { NSPasteboard *pboard = [sender draggingPasteboard]; NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType]; backgroundColor = blueColor; [self setNeedsDisplay:YES]; NSLog(@"draggingExited: filenames: %@", [filenames description]); }

-(void)concludeDragOperation:(id )sender {

/*
    This method gives you the chance to change any state variables that
    deal with dragAndDrop.

*/

NSLog(@"concludeDragOperation:"); }

@end