Auto sizing of Text View depending on typed in text
Auto sizing of Text View depending on typed in text
- Subject: Auto sizing of Text View depending on typed in text
- From: "Ashwin A Prabhu" <email@hidden>
- Date: Sat, 17 Jan 2004 14:50:27 +0530
Hi All,
I want to auto resize a Text View when user starts typing in.
A Feature that is implemented in Apple's Mail.app application.
In Mail.app application the "To:" field auto wraps the Text entered. Also
after a certain increase in width of the Text View a scroller is also
added to it.
I tried implementing the same but i am unable to get information as to
when the i reach the end of the line after which the text typed in is
placed on the next line.
Also depending on this i have to implement autosizing/shifting of other
views, Text Areas which exist around it.
Steps taken to implement this:
Nib changes:
1. Removed the scroller for the Text View by unchecking the Show
ScrollBar option in the Nib for this Text View.
2. Resized the Text View to the size of a Text field.
3. Also in the size option made the component Resizeable by attaching
springs to the component.
3. Saved the Nib.
Code Changes:
1. In the textDidChange delegate method for the Text View tried
obtaining the Text Containers size of the Text View.
2. Compared the Text Containers size(width) with the outlets width and if
its equal then increased the height of the Text view
3. But this doesnt seem to be the right way as this size sometimes
differs. and resizing is not happening properly.
4. Also tried using sizeToFit method. This is the method of NSTextViews
superclass NSText but the size doesnt change.( dont know why??)
Also had problems as to know which Outlet i am actually typing in.
e.g. if there 2 Text Views T1 and T2 and if i am typing T@ then using
NSNotification's object method can know the object but not the Outlet.
That i had to implement using a very Dirty solution:
1. Obtained the Tool tip of the object in which i typing and depending on
that i am trying to resize the view.
I couldn't get hold of any solution for these problems.
It will be a great help if you can provide me a sample code which i can
directly refer to for both of my problems.
Thanking in Advance,
Ashwin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.