Re: Problems with NSTextField and attributed strings
Re: Problems with NSTextField and attributed strings
- Subject: Re: Problems with NSTextField and attributed strings
- From: Tim Cartwright <email@hidden>
- Date: Wed, 21 Jul 2004 14:56:22 -0500
On 21 Jul 2004, at 13:50, Glenn Andreas wrote:
At 1:16 PM -0500 7/21/04, Tim Cartwright wrote:
I'm trying to use a NSTextField to display a multi-line, multi-font,
multi-language readout of some information. I set the value of field
to be a complex attributed string, which includes font settings and
paragraph styles. [...] I cannot seem to get the value of
NSMutableParagraphStyle's setParagraphSpacingBefore to affect the
display. Here's the gist of my code:
NSMutableAttributedString * fieldValue = [[NSMutableAttributedString
alloc] initWithString: @""];
NSMutableParagraphStyle * style = [[NSMutableParagraphStyle alloc]
init];
[style setParagraphSpacingBefore: 20.0]; // among other settings
NSMutableAttributedString * line = [[NSMutableAttributedString alloc]
initWithString: @"A line of text\n"];
[line addAttribute: NSParagraphStyleAttributeName value: style range:
NSMakeRange(0, [line length])];
[fieldValue appendAttributedString: line]; // among others
[myTextField setAttributedStringValue: fieldValue];
Other attributes embedded in the text field value are displaying, but
no matter what I set for the paragraph spacing before, I don't see a
change in line spacing. Does "\n" not separate paragraphs? What am I
doing wrong?
Not sure on this, but I believe that "space before" isn't used for the
for the first paragraph (since it's at the "top", just like "space
after" on the last paragraph is ignored because there's nothing after
it).
I agree with Glenn's interpretation of paragraph spacing. So, it's
worth re-iterating that I'm dealing with multiple lines. For example:
Line 1 (normal)
Line 2 (paragraph space before = 20.0)
Line 3 (paragraph space before = 20.0)
I would expect to see an extra 20 point vertical space between Line 1
and Line 2, and between Line 2 and Line 3.
Again, I'm concerned about the definition of a "paragraph" in Cocoa. I
separate my lines using "\n", which I guess would be the paragraph
separator, but I really don't know. I can't find anything in the Cocoa
documentation that explains over what textual domain a paragraph style
is supposed to apply.
-- Tim
_______________________________________________
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.