• 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: Live editing an NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Live editing an NSTextView


  • Subject: Re: Live editing an NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 26 Nov 2008 10:57:10 -0800


On Nov 26, 2008, at 4:14 AM, Arved von Brasch wrote:

I have this working almost perfectly by listening for the NSTextDidChangeNotification and searching the text for the special sequence. I've found this to be the best place to handle it, so that cut and paste operations containing the special sequence are converted properly as well. The only problem with this is that it completely screws up the Undo / Redo of the text view. It doesn't seem to be possible to use the standard shouldChangeTextInRange: and textDidChange pair, because my parser acts in response to an edit, and this would set up an infinite loop.

You need to use the should-change/did-change calls. You can protect against the infinite regress by keeping track of which changes your code is making, and not doing any work when you are notified of those particular changes. For example, you could set a flag noting that your change is in progress, and clear it when your change is done.


Douglas Davidson

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Live editing an NSTextView
      • From: Arved von Brasch <email@hidden>
References: 
 >Live editing an NSTextView (From: Arved von Brasch <email@hidden>)

  • Prev by Date: Using NSAnimation
  • Next by Date: Re: to get handle to "File/1.jpg"
  • Previous by thread: Live editing an NSTextView
  • Next by thread: Re: Live editing an NSTextView
  • Index(es):
    • Date
    • Thread