• 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: Ideal size of an NSScrollView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Ideal size of an NSScrollView?
      • From: John Stiles <email@hidden>
References: 
 >create a view without IB (From: Andrea Salomoni <email@hidden>)
 >Re: create a view without IB (From: Shawn Erickson <email@hidden>)
 >Re: create a view without IB (From: Shawn Erickson <email@hidden>)
 >Ideal size of an NSScrollView? (From: John Stiles <email@hidden>)

  • Prev by Date: Generating Scrolling Text
  • Next by Date: Re: Generating Scrolling Text
  • Previous by thread: Re: Ideal size of an NSScrollView?
  • Next by thread: Re: Ideal size of an NSScrollView?
  • Index(es):
    • Date
    • Thread