Get text height to print a custom view with NSTextView subview
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