Re: What if one can not redo and undo?
Re: What if one can not redo and undo?
- Subject: Re: What if one can not redo and undo?
- From: Florent Pillet <email@hidden>
- Date: Sat, 6 Mar 2004 16:10:42 +0100
You may be taking the wrong approach. In my code, each undoable
operation is first performed using the SAME method that is being called
for Redo. This way, you can ensure that Redo is a. always possible, and
b. consistent.
An very simple example below:
- (void)clearListOfObjects
{
[self doSetListOfOjects:nil];
}
- (void)doSetListOfObjects:(NSArray *)aList
{
// register undo action
[undoManager registerUndoWithTarget:self
selector:@selector(doSetListOfObjects:) object:listOfObjects];
[undoManager setActionName:LOCALIZED_STRING(@"undoDeleteObjects")];
// perform action
[myListOfObjects release];
myListOfObjects = [aList retain];
}
So as you see, if you write all your code with Undo/Redo support in
mind it becomes much easier. You will sometimes need to use the more
powerful -[NSUndoManager prepareWithInvocationTarget:] method (I happen
to use it a lot for complex changes), but the key point is to factor
out the code that makes a change.
Florent
On 4 mars 04, at 17:14, John Nairn wrote:
I can easily support undo of a certain action, but redo looks very
hard. The problem is after doing an undo, the undomanager activates
the unsupported redo command. Is there a way to tell the undomamager
that once an action is undone it can not be redone?
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page: http://www.eng.utah.edu/~nairn
_______________________________________________
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.
--
Florent Pillet, Code Segment email@hidden
Developer tools and end-user products for Palm OS & Mac OS X
ICQ: 117292463
http://perso.wanadoo.fr/fpillet
_______________________________________________
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.