Problem with NSLineBreakByTruncatingMiddle under 10.2
Problem with NSLineBreakByTruncatingMiddle under 10.2
- Subject: Problem with NSLineBreakByTruncatingMiddle under 10.2
- From: Tim Hewett <email@hidden>
- Date: Sat, 19 Feb 2005 15:16:07 +0000
Hi,
I am using a NSParagraphStyle with the line break mode set
to NSLineBreakByTruncatingMiddle, i.e. where truncation of
long lines is achieved by placing "..." in the middle to make
them fit (like Finder does for long filenames).
This paragraph style is used on a NSTextView, and on a
NSAttributableString used to set the attributable string value
in a cell when it gets drawn. It works for neither of these under
10.2 but is fine for both under 10.3.
So I'm wondering how to get this working under 10.2.
This is how the NSParagraphStyle is created/initialised:
myDefaultStyle = [[NSMutableParagraphStyle alloc] retain];
myDefaultStyle setLineBreakMode:NSLineBreakByTruncatingMiddle];
This is how it is applied to the text view:
[[myTextView textStorage] addAttribute:NSParagraphStyleAttributeName
value:myDefaultStyle
range:NSMakeRange( 0, [[myTextView textStorage] length] )];
This is how it is applied to the attributable string:
NSDictionary *textAttributes =
[NSDictionary dictionaryWithObjectsAndKeys:myDefaultStyle,
NSParagraphStyleAttributeName,
nil];
NSAttributedString *str = [[NSAttributedString alloc]
initWithString:stringForInit attributes:textAttributes];
As said, it works great under 10.3 but not at all under 10.2, yet
it works fine for Finder under 10.2. I'm not getting any warnings
of undefined methods being called on any objects so it seems
these methods are supported under 10.2, yet nothing is happening.
Do you have to do something different/extra to get this type of line
truncation working under 10.2? Is there something wrong with this
code for 10.2 but fine for 10.3?
Thanks,
Tim.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden