Re: Detecting when the number of lines in an NSTextView has changed (SOLVED)
Re: Detecting when the number of lines in an NSTextView has changed (SOLVED)
- Subject: Re: Detecting when the number of lines in an NSTextView has changed (SOLVED)
- From: Keith Blount <email@hidden>
- Date: Sun, 20 Feb 2005 11:36:47 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Just a quick follow up to say thank you again - the
TipWrapper example was exactly what I needed to solve
my problem. I altered the numberOfLines method in that
to become numberOfLinesInRange:. In both
textViewShouldChangeTextInRange: and textDidChange:, I
then enlarge the affected range to the nearest
whitespace character set and count the lines in that
range - if the number of lines changed between the two
methods, I know I have to update the position of my
cards. The speed when typing as fast as possible
(100wpm+) is now hugely improved.
Thanks again for the help,
Keith
--- Ricky Sharp <email@hidden> wrote:
>
> 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 You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.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