Re: Drag&Drop woes...
Re: Drag&Drop woes...
- Subject: Re: Drag&Drop woes...
- From: mmalcolm crawford <email@hidden>
- Date: Wed, 16 Mar 2005 01:27:00 -0800
On Mar 16, 2005, at 1:15 AM, <email@hidden> wrote:
I have implemented the following methods, and have done so when I
tried with NSTextView,
#import <Cocoa/Cocoa.h>
@interface MyTextView : NSTextView
{
}
@end
@implementation MyTextView
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString *type = [pb availableTypeFromArray:
[NSArray arrayWithObject:NSFilenamesPboardType]];
if (type != nil) {
return NSDragOperationCopy;
}
return [super draggingEntered:sender];
}
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString *type = [pb availableTypeFromArray:
[NSArray arrayWithObject:NSFilenamesPboardType]];
if (type != nil) {
return NSDragOperationCopy;
}
return [super draggingUpdated:sender];
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString *type = [pb availableTypeFromArray:
[NSArray arrayWithObject:NSFilenamesPboardType]];
if (type != nil) {
return YES;
}
return [super prepareForDragOperation:sender];
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString *type = [pb availableTypeFromArray:
[NSArray arrayWithObject:NSFilenamesPboardType]];
if (type == nil) {
return [super prepareForDragOperation:sender];
}
NSString *files = [[pb propertyListForType:NSFilenamesPboardType]
componentsJoinedByString:@", "];
NSLog(@"files: %@", files);
// just insert at current insertion point
[self insertText:files];
return YES;
}
@end
mmalc
_______________________________________________
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