Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

WhiteRabbit

macrumors newbie
Original poster
Jan 11, 2005
26
0
I want to have a non-editable TextField with one line of text that gets the beginning truncated so that you only see the end. The Truncate Head option seems like it only has an effect when editing.

I am using an AttributedString to set the value of the TextField with. I suspect that there may be an attribute of an AttributedString to set this but I can't find it.

I also want the field to be left alligned when the text fits within.
 
I think NSCell overrides the value inside the attributed string. Did you try setting setLineBreakMode: on the textfield cell directly?
 
Thanks, but that doesn't work either. I tried changing the allignment in the cell and the attributed string is overriding it. It also seems that IB automatically changes the options on the textfieldcell when the textfield is changed.

Is there a way to check if text is fitting within a cell? If so, I could chop the string myself. It might even be nicer since I could include an elipsis.
 
If the cell isn't overriding it, then you should be able to provide in your NSAttributedString an NSParagraphStyleAttributeName (NSMutableParagraphStyle) and setup the line break mode there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.