• 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
how can one programmatically check if text fits in cells and text-views?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how can one programmatically check if text fits in cells and text-views?


  • Subject: how can one programmatically check if text fits in cells and text-views?
  • From: Mike Morton <email@hidden>
  • Date: Mon, 15 Aug 2005 16:16:22 -0400

Folks --

If you localize nibs by extracting text and translating out of context, it’s hard to detect when the translated text no longer fits. (And even if you translate by working in IB, you may not notice problems with text which your app constructs on the fly.)

I’d like to have the debugging version of an app check for clipped text in text fields and buttons (more generally, any cell) and in NSTextViews.


Text-views are probably easy -- if it’s not in a scroll-view, set it to be resizable only vertically, then send sizeToFit and check that it didn’t grow.



Cells are trickier. For a non-wrapping cell, I hope you can just measure the text with NSFont’s widthOfString: and ensure that that’s less than the width of the cell’s titleRectForBounds:. But when I’ve done stuff like that in the past, it’s often been off by a pixel or two — maybe I did something dumb. And for a text field which wraps, how can you check if the text fits?



As is probably clear, I haven’t begun work on this, and would welcome any suggestions.


Thanks in advance,

-- Mike _______________________________________________
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


  • Prev by Date: Re: NSButtonCell columns in NSOutlineView
  • Next by Date: Re: sub-ranges for NSLink attribute
  • Previous by thread: Re: coredata during startup
  • Next by thread: Re: how can one programmatically check if text fits in cells and text-views?
  • Index(es):
    • Date
    • Thread