Dragging a attributedString containing a NSTextAttribute
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] initWith
Data:[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 set
Data: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.