• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting when the number of lines in an NSTextView has changed (SOLVED)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Detecting when the number of lines in an NSTextView has changed (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: How to determine where the kAEQuitApplication event from when on the method of [NSApplication applicationShouldTerminate] of a cocoa application
  • Next by Date: Where are IB palette directories?
  • Previous by thread: Re: Detecting when the number of lines in an NSTextView has changed
  • Next by thread: How to scroll NSView
  • Index(es):
    • Date
    • Thread