Hello all!

If this question doesn't belong on this list, please let me know, and I'll try elsewhere - thanks!

WHAT I NEED:
I'm looking to find out how many lines a given string of text will wrap to in a given NSTextField. in other words, once I know the string and the size of the field it is going into, how do I find out how many lines the system will wrap the text to? I want this because I'd like to size the NSTextField to fit snugly around the text. And the text string will change often, so I need to resize often.

WHAT I'VE TRIED:
I've looked pretty much everywhere in the Apple Docs and sample code examples. I've gotten as far as finding an instance method in the TextContainer class called usedRectForTextContainer. But I couldn't figure out how to get the Text Container for a given NSTextField. So I created a dummy (non visible) Text Container and Text Storage and Layout Manager to match the NSTextField and asked it, thru usedRectForTextContainer, to tell me how big a rect I need to display the string of text.

WHAT DOESN'T YET WORK FOR ME:
The results from usedRectForTextContainer aren't actually matching the size needed to display the text (the resulting rect is not tall enough, but not by a consistent factor). I think I'm probably not setting the font in the 'dummy' TextContainer to match the font in the actual NSTextField.

Also, is there a way to get the Text Container for a given NSTextField? (I can't find it anywhere, probably just looking in the wrong places )

In any case, this has gotten way too complicated. Is there a simpler way to do this?

I'll gladly supply the code I'm using if that would help.

Thank you in advance!!!

Paul
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to