• 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
drag-n-drop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: drag-n-drop
      • From: Chase <email@hidden>
  • Prev by Date: Re: Spotlight search speed problems?
  • Next by Date: Re: drag-n-drop
  • Previous by thread: ABPeoplePickerView
  • Next by thread: Re: drag-n-drop
  • Index(es):
    • Date
    • Thread