• 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: NSMutableAttributeString, fonts and alignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableAttributeString, fonts and alignment


  • Subject: Re: NSMutableAttributeString, fonts and alignment
  • From: Vince DeMarco <email@hidden>
  • Date: Wed, 19 Dec 2001 17:51:46 -0800

On Wednesday, December 19, 2001, at 04:16 pm, Simson Garfinkel wrote:

Thanks for the code. Unfortunately, I really do not wish to replace my 3
lines of code with the 6 lines of code that you recommend. I'm sure it will
work, but it is not the right thing for my application.

I added extra to set the tab stops, but it would still end up being a bit longer and The alignement attribute is a Paragraph attribute.

This is the correct way of doing it.

Oh well

vince


----- Original Message -----
From: "Vince DeMarco" <email@hidden>
To: "Simson Garfinkel" <email@hidden>
Cc: <email@hidden>
Sent: Wednesday, December 19, 2001 12:39 PM
Subject: Re: NSMutableAttributeString, fonts and alignment



On Tuesday, December 18, 2001, at 08:36 pm, Simson Garfinkel wrote:
What's missing is some way of setting the strings alignment. That
appears
to
be set through the setAlignment:range: method.

Unfortunately, there appears to be no way to put an Alignment into a
dictionary. (It's not defined). So I have code that looks like this:

- (void)setColor:(NSColor *)aColor
{
[dict setObject:aColor forKey:NSForegroundColorAttributeName];
[text setAttributes:dict range:NSMakeRange(0,[text length])];
[text setAlignment:NSCenterTextAlignment range:NSMakeRange(0,[text
length])]; // bug in appkit
}

I think that this is pretty ugly. I'm sure that I can hard-code the
correct
key for alignment, but I don't want to do that. I want to know what the
APPKIT_EXTERN is. Anybody know anything I don't?


Try this

{
NSMutableParagraphStyle *modifiedStyle;
NSTextTab *tabStop;

tabStop = [[NSTextTab alloc] initWithType:NSLeftTabStopType
location:100.0];
modifiedStyle = [[NSMutableParagraphStyle alloc] init];
[modifiedStyle setTabStops:[NSArray arrayWithObject:tabStop]];

[[textView textStorage]
addAttribute:NSParagraphStyleAttributeName
value:modifiedStyle range:range];
[tabStop release];
[modifiedStyle release];
}


NSParagraphStyle has this method

- (void)setAlignment:(NSTextAlignment)alignment;
_______________________________________________
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: NSMutableAttributeString, fonts and alignment
      • From: "Simson Garfinkel" <email@hidden>
References: 
 >Re: NSMutableAttributeString, fonts and alignment (From: "Simson Garfinkel" <email@hidden>)

  • Prev by Date: User Defaults
  • Next by Date: Re(4): Starting the screensaver from code
  • Previous by thread: Re: NSMutableAttributeString, fonts and alignment
  • Next by thread: Re: NSMutableAttributeString, fonts and alignment
  • Index(es):
    • Date
    • Thread