NSTextAttachment problems
NSTextAttachment problems
- Subject: NSTextAttachment problems
- From: David Dauer <email@hidden>
- Date: Mon, 14 Jun 2004 17:00:12 +0200
Hello
I'm trying to insert an image into my NSTextView. This image should have a
NSBaselineOffset from about -4. So I'm setting this up in my NSTextView
subclass like
NSString *pathToImage;
NSFileWrapper *wrapper;
NSTextAttachment *attachment;
NSMutableAttributedString *imageString;
NSData *rtfdData;
pathToImage = [[NSBundle mainBundle] pathForImageResource: @"test"];
wrapper = [[[NSFileWrapper alloc] initWithPath: pathToImage]
autorelease];
attachment = [[[NSTextAttachment alloc] initWithFileWrapper:
wrapper] autorelease];
imageString = [[[NSMutableAttributedString alloc]
initWithAttributedString: [NSAttributedString
attributedStringWithAttachment: attachment]] autorelease];
[imageString addAttribute:NSBaselineOffsetAttributeName
value:[NSNumber numberWithFloat:-4.0]
range:NSMakeRange(0,[imageString length])];
rtfdData = [imageString RTFDFromRange:NSMakeRange(0,[imageString
length]) documentAttributes:nil];
[super replaceCharactersInRange:[[super string] rangeOfString:
@"[myimage]"] withRTFD:rtfdData];
This work for my image:
{
NSAttachment = Name "test.tiff";
NSBaselineOffset = -4;
NSParagraphStyle = ...;
}
But then all text I write since creating this attachment has a baseline from
about -4:
{
NSBaselineOffset = -4; //this should NOT be there
NSFont = "CGS Helvetica 12.00 pt. P [] (0x003cc550) fobj=0x0035aa70,
spc=3.33";
NSParagraphStyle = ...;
}
How can I only set the baseline value for my image loaded in an
NSAttributedString and not for any other text?!
Thanks for any help
David
_______________________________________________
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.