Re: Auto-resizing NSTextField
Re: Auto-resizing NSTextField
- Subject: Re: Auto-resizing NSTextField
- From: Ryan Stevens <email@hidden>
- Date: Fri, 23 Dec 2005 11:03:19 -0800
On Dec 22, 2005, at 10:41 PM, Nik Youdale wrote:
Hi,
I have made a custom view which just consists of an NSView
subclass, that displays a coloured background, and then an
NSTextView in the middle. I would like the TextView to always be
just the right size to fit in the text that it contains. So
basically when you type, it grows and when you delete, it shrinks
(horizontally) I will then need to pass this size on to the NSView
to resize that as well.
I tried using [textView sizeToFit] but got no results. Also, the
text must also occupy only one line at all times, and it should not
be able to scroll or wrap.
If there is a simple method that i need i need to call that would
be great, but also if it involves running a check to see how many
pixels on screen the text occupies, and then resizing the textView
and the NSView every keystroke programatically that is also just fine.
Any help would be greatly appreciated!
Merry Christmas everyone!
FAQ..
http://www.cocoadev.com/index.pl?CCDGrowingTextField
..should get you started.
To get the frame changes to the NSView subclass you should turn on
frame change notifications for the text field and listen for them in
your NSView subclass.
Scrolling should be taken care of - since it grows as text is entered
everything should be visible. Wrapping is up to you.
Hope that helps. :)
_______________________________________________
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