Re: Auto sizing of Text View depending on typed in text
Re: Auto sizing of Text View depending on typed in text
- Subject: Re: Auto sizing of Text View depending on typed in text
- From: Gideon King <email@hidden>
- Date: Sat, 17 Jan 2004 19:38:47 +1000
You might be able to do it by overriding the layout manager delegate
method layoutManager:didCompleteLayoutForTextContainer:atEnd: method
and adjusting the text container size and text view size appropriately.
The TextEdit sample code may be of some use in this - in particular the
multi-page view and the calls to addPage and removePage - instead of
adding and removing pages you would be adjusting the size of the text
container to fit the text and the text view up to your max size and
then adding the scroller when required.
Hope this helps
Gideon
NovaMind Software
<
http://www.nova-mind.com>
On Saturday, January 17, 2004, at 07:20 PM, Ashwin A Prabhu wrote:
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.
_______________________________________________
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.