• 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
Dynamic right-sizing of TextContainer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dynamic right-sizing of TextContainer


  • Subject: Dynamic right-sizing of TextContainer
  • From: Martin Stoufer <email@hidden>
  • Date: Fri, 29 Aug 2008 11:01:57 -0700
  • Organization: LBNL

I am able to set the initial height/width of the NSTextContainer object of a NSTextView object in IB. However, I cannot find any method that will allow the programmatic re-sizing of the container when the text I'm adding exceeds this size.

Optimally, I'd like to utilize the setContainerSize with an NSSize object that just handles the amount of text that needs displaying (I'm leaving the scrolling behavior up to NSScrollView).

Currently, I'm just punting with the following in awakeFromNib:

[decimalStringView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[decimalStringView setVerticallyResizable:YES];
[[decimalStringView textContainer] setContainerSize:NSMakeSize([decimalStringView minSize].width, FLT_MAX)];


This guarantees that any string I will generate will fit in.

Where I am stuck is the height calculation for an NSSize object given a string of length N. For my purposes, the width will stay fixed. Since I know the font size (12 pt) and assuming the leading of the layout is fixed and measurable (~6px), I could calculate a new total pixel height if needed.

Is this the way to go, or should I just leave the height at the system max?

--
* Martin C. Stoufer              *
* ISS/IT                         *
* Lawrence Berkeley National Lab *
* 510-486-5306                   *
* MS 937-700                     *

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________

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

  • Follow-Ups:
    • Re: Dynamic right-sizing of TextContainer
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Checking for memory leaks with Instruments
  • Next by Date: Re: Checking for memory leaks with Instruments
  • Previous by thread: Re: Checking for memory leaks with Instruments
  • Next by thread: Re: Dynamic right-sizing of TextContainer
  • Index(es):
    • Date
    • Thread