• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa: dragging files from Finder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa: dragging files from Finder


  • Subject: Cocoa: dragging files from Finder
  • From: Marcin Górski <email@hidden>
  • Date: Thu, 3 Jun 2010 19:27:04 +0200

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 <NSDraggingInfo>)sender;
- (void)draggingExited:(id <NSDraggingInfo>)sender;
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
- (void)concludeDragOperation:(id <NSDraggingInfo>)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 <NSDraggingInfo>)sender  {
	NSLog(@"draggingEntered:");
	return NSDragOperationCopy;
}

- (void)draggingExited:(id <NSDraggingInfo>)sender {
	NSLog(@"draggingExited:");
}

- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender {
	return YES;
}

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender  {
	NSLog(@"draggingOperation");
	return YES;

}

- (void)concludeDragOperation:(id <NSDraggingInfo>)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 _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Cocoa: dragging files from Finder
      • From: Jens Alfke <email@hidden>
    • Re: Cocoa: dragging files from Finder
      • From: Markus Spoettl <email@hidden>
  • Prev by Date: Re: [iPhone] Preprocessing events sent to UITableView
  • Next by Date: Re: setting tab stops in a document
  • Previous by thread: Re: [iPhone] Preprocessing events sent to UITableView
  • Next by thread: Re: Cocoa: dragging files from Finder
  • Index(es):
    • Date
    • Thread