• 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
Dragging a attributedString containing a NSTextAttribute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dragging a attributedString containing a NSTextAttribute


  • Subject: Dragging a attributedString containing a NSTextAttribute
  • From: email@hidden
  • Date: Thu, 15 Jan 2004 10:37:53 +0100

Whats wrong whith my code?
please help!

-(void)mouseDragged:(NSEvent *)event{
NSImage *img=[[[NSImage alloc] initWithData:[self dataWithPDFInsideRect:
NSMakeRect(0,0,120,16)]] retain];
NSString *str=[NSString @"Fake text file contents"];
NSData *dat=[str dataUsingEncoding:[str fastestEncoding]];
_fileWrapper=[[[NSFileWrapper alloc] initRegularFileWithContents:dat]
retain];
[_fileWrapper setIcon:img];
[_fileWrapper setPreferredFilename:str];
[img release];
_attachment=[[[NSTextAttachment alloc] initWithFileWrapper:_fileWrapper]
retain];
NSDictionary *d=[NSDictionary dictionaryWithObject:_attachment forKey:
NSAttachmentAttributeName];
NSAttributedString *atts=[[[NSAttributedString alloc] initWithString:@""
attributes:d] retain];
NSData *rtfdData=[atts RTFDFromRange:NSMakeRange(0,[atts length])
documentAttributes:nil];
NSPasteboard *pb=[NSPasteboard pasteboardWithName:NSDragPboard];
[pb declareTypes:[NSArray arrayWithObject:NSRTFDPboardType] owner:self];
[pb setData:rtfdData forType:NSRTFDPboardType];
[self dragImage:[_fileWrapper icon] at:NSMakePoint(0,0) offset:
NSMakeSize(0,0) event:event pasteboard:pb source:rtfdData slideBack:YES];
}



__________________________________________________________


http://www.wanadoo.nl/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Frame Information (Backtrace)
  • Next by Date: Re: Cocoa App daemon with NSPanel
  • Previous by thread: Frame Information (Backtrace)
  • Next by thread: Saving "objects" & opening them up in a non-document based App
  • Index(es):
    • Date
    • Thread