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: Keith Blount <email@hidden>
- Date: Sun, 20 Feb 2005 03:04:49 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Many thanks for you reply, much appreciated - I am
downloading the TipWrapper example right now and will
check out the line count methods.
I tried delaying the movement of the margin cards
until after the user has stopped typing - it speeds
things up, but it looks really ugly and unnatural, so
I think it would still be best if I can just optimise
their "live" movement by detecting whenever the number
of lines in the text view has changed in the quickest
way possible.
Thanks again, and any other suggestions much welcomed.
All the best,
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!?
Yahoo! Mail - You care about security. So do we.
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