Re: Ideal size of an NSScrollView?
Re: Ideal size of an NSScrollView?
- Subject: Re: Ideal size of an NSScrollView?
- From: John Stiles <email@hidden>
- Date: Tue, 20 Dec 2005 13:53:09 -0800
Thanks to multiple suggestions, I found what appears to be a working
solution. Thanks everyone :)
NSLayoutManager *layoutManager = [textView layoutManager];
NSRect rect = [layoutManager boundingRectForGlyphRange:NSMakeRange
(0, [layoutManager numberOfGlyphs]) inTextContainer:[textView
textContainer]];
"usedRectForTextContainer" also appears to be a working solution, but
it doesn't force glyph layout, so you can get stale information back.
"boundingRectForGlyphRange," OTOH, does force layout.
On Dec 19, 2005, at 7:02 PM, John Stiles wrote:
I have a regular NSTextView inside an NSScrollView (with an auto-
hiding vertical scroll bar). The contents of the text view are set
via code depending on the outcome of some operations. The scroll
view is set up to grow as my window is resized. So far, everything
is working great.
Now, I'd like to be able to determine how large the NSTextView
ought to be to avoid scrolling. That way, I can set the window to
its "optimal" size before showing it--just big enough to show the
text, without having a ton of extra white space.
Is there an easy way to do this?
(I tried gradually growing the window until [scrollView
hasVerticalScroller] returned NO, but that didn't work; apparently
it returns YES even if the scroller is hidden. I also tried looking
at the contentSize and documentVisibleRect but it didn't seem to do
what I wanted.)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com
This email sent to email@hidden
_______________________________________________
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