NSText textDidChange: doesn't report undo in text view
NSText textDidChange: doesn't report undo in text view
- Subject: NSText textDidChange: doesn't report undo in text view
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 05 Jul 2002 14:49:03 -0400
Today I independently rediscovered the problem with NSText's textDidChange:
delegate method that Jim Correia talked about recently. I wonder if there
are any further thoughts on how to deal with it?
The problem is that the textDidChange: delegate method isn't triggered by
undo and redo commands in a text view. The textDidChange: delegate method is
implemented in NSText, but undo and redo are implemented in NSTextView.
NSText is NSTextView's parent, and the parent doesn't know about the child's
undo capability. This problem is acknowledged indirectly by omission,
apparently with some embarrassment, in a comment on textDidChange: in the
NSText header file -- "Any keyDown or paste which changes the contents
causes this."
I use NSText's textDidChange: delegate method to update my application's
text data object continuously. This works nicely for typing, cutting,
pasting, and dragging. But it doesn't work at all for undo and redo. If my
users undo and redo changes in the text view, the text data object simply
never finds out about it. This is intolerable.
What's the workaround? Should I use NSTextStorage instead of my own text
data object. I not only need an up-to-date text data object, but I need to
be able to see my user's typing (and undoing) simultaneously in two separate
text views.
Even if using NSTextStorage proves to be feasible, it seems to me that
NSTextView needs to be revised to override NSText's textDidChange: delegate
method, to pick up and report the undo and redo events. I wonder if this can
be done in a category on NSTextView? Should I put this on RadarWeb as a
bug/feature request?
Hmmm.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.