• 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
Get text height to print a custom view with NSTextView subview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get text height to print a custom view with NSTextView subview


  • Subject: Get text height to print a custom view with NSTextView subview
  • From: David Sinclair <email@hidden>
  • Date: Wed, 5 Jan 2005 23:29:41 -0800

I am attempting to print a custom view that contains multiple other views as subviews. All of which works fine, except for a NSTextView.

I construct a special off-screen instance of the custom view for printing, and add the subviews from nibs. The issue with the text view is that I need to resize it to fit the text to be printed, but I can't find a way to find out the appropriate height.

I searched the archives, and found a few suggestions, like using a temporary NSTextField and calling -sizeToFit, but that resizes both horizontally and vertically, whereas I need it to only resize vertically (and -setHorizontallyResizable: doesn't help in this situation).

I thought I could just ask the text view to calculate its size via the layout manager, but it doesn't appear to do that till in the background in the run loop -- I need to get the size immediately after assigning the text.

Put another way: given a NSTextView with arbitrary content (styled text, images, etc) and a known width, how can I immediately find out the appropriate height?

Can anyone help me, or point me to an archive or sample code solution?

--

David Sinclair, Dejal Systems, LLC - email@hidden
Custom Mac OS X development - http://www.dejal.com/consulting/
Site change and failure monitor tool - http://www.dejal.com/simon/
Plus other useful Mac products - http://www.dejal.com/products/

_______________________________________________
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: Get text height to print a custom view with NSTextView subview
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: OT: Database of IP locations?
  • Next by Date: Re: [OT] user banned from the list
  • Previous by thread: Re: newbie view help understanding (rulers example)
  • Next by thread: Re: Get text height to print a custom view with NSTextView subview
  • Index(es):
    • Date
    • Thread