• 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
Re: Drag&Drop woes...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Drag&Drop woes...
      • From: mmalcolm crawford <email@hidden>
References: 
 >Re: Re: Drag&Drop woes... (From: <email@hidden>)

  • Prev by Date: Re: Re: Drag&Drop woes...
  • Next by Date: Moderator: Re: multidimensional arrays
  • Previous by thread: Re: Re: Drag&Drop woes...
  • Next by thread: Re: Drag&Drop woes...
  • Index(es):
    • Date
    • Thread