• 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
NSTextAttachment problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: NSTextAttachment problems
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: InputManagers
  • Next by Date: Re: even after the longish diatribes on copying....
  • Previous by thread: Re: #define works, const short does not for Ctype array in class
  • Next by thread: Re: NSTextAttachment problems
  • Index(es):
    • Date
    • Thread