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

Autoresizable NSTextField


  • Subject: Autoresizable NSTextField
  • From: Lorenzo <email@hidden>
  • Date: Fri, 29 Oct 2004 15:38:55 +0200

Hi there,
I made a TextField autoresizable and I almost succeed.
Every time I type within the field I resize the field using textDidChange
method. It works well until the field width goes over its original width
when I started the editing. I see the field with the new correct width, but
the new area is white (no visible text).
I suppose that its NSCell doesn't update itself with the new width.
How to fix this?

- (void)textDidChange:(NSNotification *)aNotification
{
NSAttributedString *aString = [[self cell] attributedStringValue];
NSDictionary *attrDict;
float strWidth ;

attrDict = [aString attributesAtIndex:0 effectiveRange:nil];
strWidth = [[aString string] sizeWithAttributes:attrDict].width + 4;

[self setFrameSize:NSMakeSize(strWidth, [self frame].size.height)];

[self setNeedsDisplay:YES];
[[self superview] setNeedsDisplay:YES];
}


Best Regards
--
Lorenzo
email: 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

  • Prev by Date: is there a tool that displays object relationships in Cocoa?
  • Next by Date: Re: is there a tool that displays object relationships in Cocoa?
  • Previous by thread: Re: is there a tool that displays object relationships in Cocoa?
  • Next by thread: Const help
  • Index(es):
    • Date
    • Thread