Re: Detecting when the number of lines in an NSTextView has changed
Re: Detecting when the number of lines in an NSTextView has changed
- Subject: Re: Detecting when the number of lines in an NSTextView has changed
- From: Ricky Sharp <email@hidden>
- Date: Sat, 19 Feb 2005 09:20:57 -0600
On Feb 19, 2005, at 6:28 AM, Keith Blount wrote:
I am currently trying to optimise a view I have been
working on which has margin notes aligned next to text
in an NSTextView. Currently, whenever the text in the
text view changes, I calculate the position of the
characters to which any notes are attached in the
layout manager and then move the margin notes
accordingly.
So far, so good, but there is some slowdown if there
are lots of margin cards and the user types at the top
of the text (because all of the margin cards below
that place in the text have to have there position
recalculated whenever the user types anything).
Perhaps delay the recalc until the user stops typing. i.e. set up or
reset a one-shot timer whenever you get a keydown. Once it's allowed
to fire, perform the expensive operation.
What I would like to do is only calculate new
positions for the margin cards if the number of lines
in the text view changes - this way there would only
ever be slowdown when the user hits return or typing
spills over onto another line.
[rest snipped]
I'm not sure if the TipWrapper example may be what you need. I think
it probably does the same expensive operations as you've described, but
it's worth a look.
Specifically look at the NSTextView_Lines.h/.m. It provides a category
on NSTextView where you can obtain a line count.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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