drag and drop images to NSWindow doesn't work
drag and drop images to NSWindow doesn't work
- Subject: drag and drop images to NSWindow doesn't work
- From: "Bill So" <email@hidden>
- Date: Tue, 25 Sep 2007 01:43:19 +0800
Dear all,
I m trying the drag n drop behavior of NSWindow using the following excerpt:
- (void)awakeFromNib {
NSArray *myAy = [NSImage imagePasteboardTypes];
[window registerForDraggedTypes:myAy];
//[window registerForDraggedTypes:[NSArray
arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, nil]];
}
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender {
NSLog(@"Hello");
}
- (void)draggingExited:(id < NSDraggingInfo >)sender {
NSLog(@"dragging exit");
}
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender {
//check to see if we can accept the data
return [NSImage canInitWithPasteboard: [sender draggingPasteboard]];
}
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender {
// add the image to the source image array
// render layout
NSLog(@"Performing drag operation");
return YES;
}
However, if I use the image pasteboard types, the sample app doesn't
respond to any image dragging into the window.
If I use the commented code in "awakeFromNib" instead, it prints those
debug message.
What's wrong?
Please kindly help.
Best Regards,
Bill
_______________________________________________
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