• 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: NSTextField & sizeToFit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField & sizeToFit


  • Subject: Re: NSTextField & sizeToFit
  • From: Andre Lipinski <email@hidden>
  • Date: Mon, 11 Jun 2001 15:28:30 -0400

On Monday, June 11, 2001, at 12:20 AM, Russell Ahrens wrote:

It's ugly, but what I did to make it work is the following:

- (void)textDidChange:(NSNotification *)notification {
// temporary string to hold the current value of the NSTextField
// and to plop it back in to fool the ?event loop? ?the TextField?
// well, SOMETHING into thinking that the text should be resized now
NSString * temp;

// only size the field as wide as it needs to be, no more
[field sizeToFit];
// inform the display system that the field is ready for redisplay
[field setNeedsDisplay:YES];

// crazy hacktastic way to REALLY make the system redisplay
temp = [field stringValue];
[field setStringValue:temp];

}

There has GOT to be a better way. I haven't found it yet; I would think that just sizeToFit followed by setNeedsDisplay should be enough. Hopefully someone more experienced can correct me?


This only works for me when I make the field smaller than it was previously. The thing is the cell doesn't get larger, or doesn't realise it must re-display a larger area. I've tried the various NSCell routines to get it to recalculate its drawing space, but it won't do as I ask.

I wonder now if this is a bug?

Andre


References: 
 >Re: NSTextField & sizeToFit (From: Russell Ahrens <email@hidden>)

  • Prev by Date: Re: Obtaining Current User Name
  • Next by Date: Re: Static variable in Obj-C way?
  • Previous by thread: Re: NSTextField & sizeToFit
  • Next by thread: Re: NSTextField & sizeToFit
  • Index(es):
    • Date
    • Thread