Re: Live editing an NSTextView
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