Hello,
I’m new to Cocoa programming. I would like to be able to drag filenames from Finder to a custom view in my application. Both previous mails and Mr. Google redirect to Drag and Drop Programming Topics for Cocoa (http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/) . I’ve read this, but something still doesn’t work.
Declaration of my custom view (a subclass of NSView) looks like:
@interface myView : NSView { } – (NSDragOperation)draggingEntered:(id )sender; – (void)draggingExited:(id )sender; – (BOOL)prepareForDragOperation:(id )sender; – (BOOL)performDragOperation:(id )sender; – (void)concludeDragOperation:(id )sender; @end
then I have a dummy implementation that does nothing but writes to debugging console :
@implementation myView – (id)init { [super init]; [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]]; return self; }
- (NSDragOperation)draggingEntered:(id )sender { NSLog(@”draggingEntered:”); return NSDragOperationCopy; }
- (void)draggingExited:(id )sender { NSLog(@”draggingExited:”); }
- (BOOL)prepareForDragOperation:(id )sender { return YES; }
- (BOOL)performDragOperation:(id )sender { NSLog(@”draggingOperation”); return YES;
}
- (void)concludeDragOperation:(id )sender { NSLog(@”draggingFinished:”); }
In my AppController class (main class in app) I create new myView object and in Interface Builder this object is connected with a Custom View layout. But when I run my app and try anything from Finder the console remains silent. Can anyone tell me what I’m missing?
Thanks, Marcin _______________________________________________