Kevin, thanks for that. This was exactly the problem. My text view subclass 
asks its delegate for an undo manager, and I forgot to implement the delegate 
method in this particular document subclass.

Many thanks!

Martin

On May 23, 2012, at 07:00 PM, Kevin Perry wrote:

> 
> On May 23, 2012, at 9:43 AM, Martin Hewitson <martin.hewit...@aei.mpg.de> 
> wrote:
>>> It is indeed -updateChangeCount: that controls the 'Edited' state. You 
>>> might try overriding with a call to super and setting a breakpoint or 
>>> adding a log to make sure it's being called as expected (with 
>>> NSChangeDone). That should be getting called by the undo mechanism, but it 
>>> would be good to verify.
>> 
>> It's being called only once when the document is loaded. It gets called with 
>> NSChangeCleared, which I guess is what you would expect. I've no idea why it 
>> isn't called after edits.
>> 
>> If I return NO from autosavesInPlace, I see the same behaviour. The dirty 
>> dot in the red button does not appear after an edit. If I listen for text 
>> did change notifications from the text view and call -updateChangeCount in 
>> there, then everything works normally.
> 
> Perhaps the NSTextView's NSUndoManager isn't the same as the NSDocument's?
> 
> This is supposed to work automatically, but maybe you've done something to 
> prevent this. If its delegate doesn't specify one, the NSTextView searches 
> the responder chain for something that responds to -undoManager. Usually 
> that's the NSWindow. If its delegate doesn't specify one, the window will get 
> its undo manager from [[[self windowController] document] undoManager].
> 
> Compare the pointers of [textView undoManager] and [document undoManager]. I 
> suspect they're different.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to