• 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: Truncating rich text in NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Truncating rich text in NSTextField


  • Subject: Re: Truncating rich text in NSTextField
  • From: Camillo Lugaresi <email@hidden>
  • Date: Thu, 26 Jan 2006 21:02:47 +0100

On 26/gen/06, at 20:14, Joshua Scott Emmons wrote:

When plain NSTextFieldCell has been set with - setLineBreakMode:NSLineBreakByTruncatingTail, text entered into the text field is automatically truncated by ellipsis (…).

However, if the NSTextField is set to handle rich text through a call to -setAllowsEditingTextAttributes:YES, the text no longer wraps. A quick look at the -attributedStringValue: of the field shows that this is because the NSParagraphStyle's LineBreakMode attribute is ignoring NSTextField's -lineBreakMode: setting and instead going with a default of NSLineBreakByClipping.

I've submitted a bug to Apple about this, but am looking for a work around. I thought the solution would be to programatically fill the text field with an NSAttributedString that already had LineBreakMode set to NSLineBreakByTruncatingTail. This works as long as my attributed string contains some text. But if I try to specify a string with said attributes and no text (@""), all I get returned reference to nil, which obviously doesn't contain any attributes.

I also noticed that the field editor's -textStorage: defaults to the incorrect LineBreakStyle of NSLineBreakByClipping. If I replace it with the proper LineBreakMode, everything truncates as expected. But I run into the same problem as above: I can't actually specify attributes for the field editor unless I also specify text.

So I'm out of ideas. Does anyone else see a solution? An error in my reasoning? Anything?

Add the attribute when the user has finished editing the text and leaves the field.


Camillo _______________________________________________
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: 
 >Truncating rich text in NSTextField (From: Joshua Scott Emmons <email@hidden>)

  • Prev by Date: Re: CoreData: Intermittent crash in -[NSSQLRow dealloc]
  • Next by Date: Re: realreplayer style NSWindow
  • Previous by thread: Truncating rich text in NSTextField
  • Next by thread: realreplayer style NSWindow
  • Index(es):
    • Date
    • Thread