• 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: Measuring length of string compared to text field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Measuring length of string compared to text field


  • Subject: Re: Measuring length of string compared to text field
  • From: Allan Odgaard <email@hidden>
  • Date: Fri, 2 Apr 2004 11:06:10 +0200

On 2. Apr 2004, at 9:57, Chad Armstrong wrote:

Is there a way to tell if a string is too long for a text field within the code? I'm trying for an effect similar to when one empties the trash which contains a file with a long file name, and the file name has an ellipsis (...) at the end to indicate there is more to the name.

Not entirely sure what you want, but maybe NSLineBreakByTruncatingTail is the solution? I think this was implemented in Panther.

Is there a solution to my problem? I'm currently using the Lucida Grande font.

It's rather difficult because there is padding, borders and such to take into consideration -- but one solution might be to clone the cell used for the text and send it a sizeToFit. That way you can compare that size with the interior of the view which display the real cell.





** Cocoa FAQ: <http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Measuring length of string compared to text field (From: Chad Armstrong <email@hidden>)

  • Prev by Date: Re: Embedding a Check Box in an NSTableView
  • Next by Date: Rotating view whilst printing
  • Previous by thread: Measuring length of string compared to text field
  • Next by thread: Re: Measuring length of string compared to text field
  • Index(es):
    • Date
    • Thread