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: "Ashwin A Prabhu" <email@hidden>
- Date: Mon, 19 Jan 2004 19:01:00 +0530
Hi Gideon,
Thanks for your prompt reply.
It was of great help to me.
But by using this method i am able to increase the size of the Text view
but not decrease it.
I increase the TextView size as explained below:
1. First set the size of the TextViews Container to that of
TextViews(Outlet) Size.
2. In the windowControllerDidLoadNib set the delegate of the TextView's
Layoutmanager to the controller class where the delegate method is
overridden.(used the setDelegate method)
Now on each type in of a character this delegate method is called.
The delegate method has three parameters which are input to this method,
namely LayoutManager,textContainer and a Boolean flag.
When we utilise the existing container space, the flag value changes to
FALSE/NO(int value 0) and if flag Value is False then we increase the
Size(width is kept constant, height is increased) of the Container and the
TextView.
But now if i start deleting the typed in characters and after deleting a
whole line i want to decrease the size of the of the TextView, such that
it just accommodates whatever is typed in.
So basically i want to know how can we get notified that we deleted the
whole line and the cursor has reached the line above it.
Cheers,
Ashwin.
Gideon King <email@hidden>
01/17/04 03:08 PM
To: Ashwin A Prabhu <email@hidden>
cc: email@hidden
Subject: Re: Auto sizing of Text View depending on typed in
text
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.