Re: drag and drop images to NSWindow doesn't work
Re: drag and drop images to NSWindow doesn't work
- Subject: Re: drag and drop images to NSWindow doesn't work
- From: Dominik Pich <email@hidden>
- Date: Mon, 24 Sep 2007 20:18:06 +0200
Different types i'd guess.With myAny youonly accept images.
With the commented code URLs and paths.
Often an app may not directly put a lot of data on the pasteboard
(although there is a protocol to provide data lazily) but merely a
reference to it.
On 24.09.2007, at 19:43, Bill So wrote:
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
_______________________________________________
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