Autofill a text view with newlines
Autofill a text view with newlines
- Subject: Autofill a text view with newlines
- From: Keith Blount <email@hidden>
- Date: Thu, 28 Oct 2004 12:21:18 -0700 (PDT)
Hello,
I would be very grateful if somebody could help me
with the following issue:
I have two text views alongside one another. One is
used to contain the main text, the other is used for
making brief notes on that text. Whenever the main
text view has a document loaded into it (eg. an RTF),
the other text view should be filled with newline
characters so that the user can scroll down anywhere
in the document and still be able to click into the
notes text view and start typing from there.
I have tried implementing this but it has some
annoying problems. My first method was this:
1) Monitor NSViewFrameDidChangeNotifications.
2) Upon a change, check to see the sender is the notes
view or the main view.
3) If it is either, check to see if the notes view
bounds size.height is less than the main text view
bounds size.height.
4) If so, add a newline to the end of the notes view.
-> 4) will cause the frame of the notes view to
change, kicking off the whole sequence again, until
the two views are approximately the same size and the
notes view is filled with newlines.
This method works, but it is sloooow. I guess this is
because it adds a newline character, then waits for
the notification, then starts again - it can take a
minute or two to fill the notes view with newline
characters when loading a long document, which is
obviously unacceptable.
So then I tried adding a for... loop, as follows:
1) - 3) the same as above.
4) If so, call a for loop like this:
for (i = notes view height; i < main view height; i +=
notes font height)
add newline to end of notes view
But this doesn't work well either - in this case, too
many newlines get added for some reason - twice as
many as required, I think, and I can't seem to be able
to fix it.
If anybody has a good suggestion of how I can fill one
text view with newline characters (quickly) so that
its height matches that of an adjacent text view, I
would be *really* grateful.
Many thanks,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
_______________________________________________
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