Autoresizable NSTextField
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