Re: How to detect clipping of text in NSTextView?
Re: How to detect clipping of text in NSTextView?
- Subject: Re: How to detect clipping of text in NSTextView?
- From: John Stiles <email@hidden>
- Date: Wed, 27 Jun 2007 09:51:54 -0700
On Jun 27, 2007, at 9:40 AM, Douglas Davidson wrote:
On Jun 27, 2007, at 9:05 AM, Leon Starr wrote:
I have an NSTextView with a fixed width that resizes vertically
up to a maximum depth (two lines).
The user may enter a string a bit longer than what I am allowing the
text view to display. (I don't want to resize the view to
accommodate
the text).
I would like to display a visual cue so that the user knows text has
been clipped. Like a + sign or something.
Is there some notification that will tell me when the text view's
container
begins to clip text?
I know that I can use -sizeWithAttributes to get a single-line
bounding box
size, but that doesn't take into account line wrapping. Otherwise
I could just
compare bounding box sizes on each text change. (Worst case, I
suppose
I could just work out the line wrap computation myself...)
Talk to the layout manager. It will tell you, for example, which
glyphs are laid out in a particular text container. If that isn't
all of them, then not everything is being displayed. If you need
notification, you can act as the layout manager's delegate and be
notified when layout happens and/or is finished.
Also, FWIW, Mac OS applications typically denote truncation with the
ellipsis (…).
Many Cocoa controls will automatically truncate their text this way,
but the text view unfortunately doesn't AFAIK.
_______________________________________________
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:
This email sent to email@hidden