• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What if one can not redo and undo?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >What if one can not redo and undo? (From: John Nairn <email@hidden>)

  • Prev by Date: Re: Addressbook style textfield
  • Next by Date: Runloops, Cocoa and Carbon
  • Previous by thread: Re: What if one can not redo and undo?
  • Next by thread: [NSWindow setIgnoresMouseEvents] support on Jaguar?
  • Index(es):
    • Date
    • Thread