• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextField and NSLineBreakByTruncatingMiddle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField and NSLineBreakByTruncatingMiddle


  • Subject: Re: NSTextField and NSLineBreakByTruncatingMiddle
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 23 Jan 2006 14:08:49 -0600

On 20 Jan 2006, at 9:18 PM, Joshua Scott Emmons wrote:

[[myTextField cell] setWraps: YES];
or
[[myTextField cell] setWraps:NO];
[[myTextField cell] setLineBreakMode:NSLineBreakByTruncatingMiddle];

But neither of these behaves as I would expect. Both prevent the text from wrapping (as the lines are no longer being split on words), but neither does anything to truncate the string. I'm pretty sure NSLineBreakByTrunca[t]ingMiddle is supposed to be working in 10.3+, right? I'm working in 10.4, and getting no love. Am I just horribly misusing -setLineBreakMode:?

1. The documentation for -[NSCell setLineBreakMode:] says that this method was introduced in 10.4, so your question about its working in 10.3 is moot.


2. The documentation for -[NSCell setWraps:] says "Calling this method with the value YES is equivalent to calling the setLineBreakMode: method with the value NSLineBreakByWordWrapping." So I'd avoid setWraps: as being immediately discarded by setLineBreakMode:.

3. I did a small test application, consisting of a window with two NSTextFields known to the application delegate as truncatedField and plainField. My awakeFromNib method is:

- (void) awakeFromNib
{
[[truncatedField cell] setLineBreakMode: NSLineBreakByTruncatingMiddle];
}


When I run the application, too-long input scrolls the plain field horizontally, and when I exit the field, it displayed from the beginning, visually truncating it at the right margin:
This text is too long for the space provided
=> This text is too long for the spac


When I type too-long text into truncatedField, the text scrolls horizontally as I type it, but when focus leaves the field, the contents are shown middle-truncated:
This text is too long for the space provided
=> This text is too...space provided


An experiment shows that sending setWraps: to the truncatedField's cell does not prevent middle-truncation.

Something is happening in your code (or your input to the field) that you aren't telling us.

	-- F

_______________________________________________
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


References: 
 >NSTextField and NSLineBreakByTruncatingMiddle (From: Joshua Scott Emmons <email@hidden>)

  • Prev by Date: Cannot Add an Custom -initWithArg: in a Category?
  • Next by Date: Re: NSTextView - custom pasteboard types and text table issues
  • Previous by thread: NSTextField and NSLineBreakByTruncatingMiddle
  • Next by thread: Document Packages Examples...
  • Index(es):
    • Date
    • Thread