Re: Document still modified after last Undo
Re: Document still modified after last Undo
- Subject: Re: Document still modified after last Undo
- From: Andre <email@hidden>
- Date: Fri, 28 Apr 2006 08:57:11 -0700
On 平成 18/04/28, at 7:03, David Catmull wrote:
On Apr 27, 2006, at 10:59 PM, email@hidden wrote:
Its because at the end of the runloop is when an undo finishes its
"recording."
Ah, that's right. I totally forgot about the run loop thing.
OK, so I can understand why groups aren't needed in this case. But
why do they cause problems?
Its probably a bug, because it seems, at least in my case, and in
yours it seems, that the last undo gets performed correctly,
its just that the document still thinks its dirtly. When I pursued
this further, like adding more undos and undoing again, going back
and forth,
my app got into an "inconsistent" state where undoing and redoing
just wouldn't work anymore (its caused when the undo manager gets
more groupings or un-groupings than the other.)
So, I was reluctant to work around it, and just pulled everything,
and happily enough it all works fine now.
I'm going to want to use undo groups for some things - for example,
if I change an object's color five times, I don't want to have to
undo those changes individually.
Yes, I know exactly what your saying, and here's something very
interesting. Im not sure if its built into NSUndoManager per se, but
at least some cocoa classes
are smart enough that when you change a value at a certain frequency
within a certain amount of time, (say 5 recorded (undoable) changes
within a 2 second period) they are automatically lumped together into
1 big undo.
You can see this in action by making a really simple test app that
has a single core data entity, that has a binary type attribute.
Bind a simple image well to an NSObject or NSArrayController that
manages this kind of entity.
Drop an image, 1 every 1 or 1.5 seconds onto the image well, so the
binary data gets put into your selected object.
Notice if you do this 5 times, there should be exactly 5 undos.
Now, within a shorter time, try to drag and drop as many different
images as you can in the same 5 sec period. If you can get 2 images
dropped a sec or more, then when your done,
you may notice that when you click undo, it reverts straight back to
the state before you started dragging anything.
This is similar to how NSTextView behaves, it doesn't record every
key typed, just the textual changes within a certain period of time.
So if you type real slow, undo will undo every key stroke, but if you
type real fast, then undo may remove a whole paragraph!
Its interesting, this behavior.......... very useful, but a little
tricky at first.
So if someone drags a color off of the color well, or into a color
well, like you suggested, try and see, (without doing your own undo
groups) what happens if the user changes the value quickly.... does
undo change each individual change or is it lumped together if you do
it quickly enough, like in the image well example?
Andre
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden