Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Silly NSTextFieldCell tricks



Peter Ammon wrote:

On Jan 31, 2008, at 11:27 AM, John Stiles wrote:

I've noticed that in table views, the NSTextFieldCell has the ability to ever-so-slightly squash its contents horizontally, to fit inside the table cell, before eventually giving up and truncating them with ellipses.

Is there any way for me to programmatically do the same thing to my own NSTextFieldCell?

As I'm typing this, suddenly I'm thinking "maybe I could fake it by altering the cell's bounds while leaving the frame alone"… but is there a better way? Changing the bounds would make the text thinner, which isn't quite the same as squeezing the letters more tightly together.

Hi John,

This is called "tightening" in the API, and it's enabled by default on text fields (actually, on any control) when the line break mode is one of the three truncation line break modes in NSParagraphStyle.h. You can control the threshold between tightening and truncation with the setTighteningFactorForTruncation: method on NSMutableParagraphStyle.

Hope that helps,
-Peter
Cool!
Is there any way to enable this for an NSTextField in a window? Someone off-list suggested using attributed strings to do this, but is that the best way?


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden
References: 
 >Silly NSTextFieldCell tricks (From: John Stiles <email@hidden>)
 >Re: Silly NSTextFieldCell tricks (From: Peter Ammon <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.