a minor undo/redo question...
a minor undo/redo question...
- Subject: a minor undo/redo question...
- From: Steve Mykytyn <email@hidden>
- Date: Mon, 16 Sep 2002 12:30:51 -0700
i'm having trouble sorting out undo/redo - it almost works right - in
fact it does when you alternate "undo" and "redo" actions... i' m
having trouble when "undo" is selected multiple times - seems to push
more undos onto the stack...
XMDocument, a subclass of NSDocument (no NSWindowController) has this
method to handle a selection on an NSColorWell:
- (IBAction) setColorHigh:(id)sender {[self
resetColorHigh:[themeColorHigh color]];}
where IBOutlet NSColorWell *themeColorHigh; is the NSColorWell the user
modified...
the following method was intended to both handle the user making the
change, and the undo/redo actions (basically, save and restore the
color)
- (void) resetColorHigh:(NSColor *)aColor {
XMTheme *aTheme = (XMTheme *)[[theData themeList]
getSelectedObject ];
NSColor *oldColor = [ aTheme colorHigh ];
NSUndoManager *myUndoManager = [self undoManager];
if (aTheme==nil) return;
[myUndoManager registerUndoWithTarget:self
selector:NSSelectorFromString(@"resetColorHigh:") object:oldColor];
[myUndoManager setActionName: @"thematic color change"];
[ aTheme setColorHigh:aColor ];
[self showColorHigh:aColor];
}
The first two lines get the "model" value of the NSColor into
"oldColor", then the undo is registered, and finally the model value is
update to "aColor" and the NSColorWell itself is changed to show
"aColor" (this is of course redundant in the case when the user clicked
the color well, as opposed to using the Undo/Redo stuff)
I've read the discussion on mamasam but there wasn't anything that was
clear enough to me, at least... help greatly appreciated
_______________________________________________
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.