Re: NSDocument override Undo's default handling of changes count
Re: NSDocument override Undo's default handling of changes count
- Subject: Re: NSDocument override Undo's default handling of changes count
- From: Graham Cox <email@hidden>
- Date: Mon, 1 Feb 2010 21:38:13 +1100
On 01/02/2010, at 9:27 PM, Ernesto Giannotta wrote:
> Hello list,
>
> I'm using NSDocument default undoManager but want to override it's change counting behaviour
> (I want the black modifed dot to not show when some minor changes are done, but still have them undoable)
>
> I've discovered it's internally handled by these methods observing the undoManager's notifications:
>
> - (void) _changeWasDone: (NSNotification *)notification
>
> - (void) _changeWasUndone: (NSNotification *)notification
>
> - (void) _changeWasRedone: (NSNotification *)notification
>
> I can hack these just fine by overriding them in my NSDocument subclass but I feel uncomfortable with that
> (and with those compiler warnings obviously thrown by XCode)
>
> I've also tried to intercept the undoManager's notifications
> which I can do but can't find a way to prevent them from propagating to the default handlers
>
>
> Am I missing something or should I implement my own undoManager just to handle this minor tweak?
You can override the public method -updateChangeCount: which I think the private methods you mention call.
The difficulty you will have is to detect which undo task was "major" and which was "minor", since the default undo manager makes no distinction. That strikes me as your biggest problem here.
On the other hand, why confuse your users? If something's important enough to be undoable it should be important enough to save, so should set the dirty flag. Every other app does that, so yours will appear broken, with undoable changes not allowing a save. The user will not be able to tell what is 'major' and what is 'minor' as you've decided that for them, without giving them a proper way to tell. Alternatively, if a change really is minor, why bother making it undoable?
--Graham
_______________________________________________
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