jerrykrinock / CategoriesObjC

General-purpose categories of Cocoa classes.
Other
274 stars 41 forks source link

NS(Attributed)String+Geometrics gets wrong height of text in NSTextField on Lion #1

Open vinceyuan opened 12 years ago

vinceyuan commented 12 years ago

Thanks for sharing NS(Attributed)String+Geometrics.

I downloaded the demo project and ran it on Mac OS X Lion. The height of text in NSTextView+NSScrollView is always correct, but the height of text in NSTextField is not correct. Sometimes it is a little bit shorter and sometimes it is much longer.

PS. You have to resize the window to see the green arrow on Lion.

I did not find any problem in the code. Need some experts to take a look at it. Thanks.

jerrykrinock commented 12 years ago

Hello Vince,

Regarding the discrepancies in measuring NSTextField, I discovered this myself and I think have explained it near the top of the header file NS(Attributed)String+Geometrics.h. See the section titled "RENDERING IN NSTextView VS. NSTextField". If I remember correctly, the reason why it sometimes measures low and other times high depends on whether or not a final line wrap occurs. The short answer is: Don't use a multi-line NSTextField in real projects. Use NSTextView instead.

As far as the green line in Lion, let me know if you find a fix for that :)

I haven't tried it, but I'm hoping that some of this stuff may be obviated by Auto Layout in Lion?