Further undo improvements.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20562 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-01-16 11:38:23 +00:00
parent 7e6ddd83a6
commit 310d3464fd
2 changed files with 53 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2005-01-16 06:39 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSDocument.m: In validateMenuItem: added code to
properly set the undo/redo title and disable the menus when
appropriate.
2005-01-15 05:59 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSDocument.m: Added undo:/redo: here. Smarter use

View file

@ -579,12 +579,56 @@
- (BOOL)validateMenuItem: (NSMenuItem *)anItem
{
if ([anItem action] == @selector(revertDocumentToSaved:))
return ([self fileName] != nil && [self isDocumentEdited]);
BOOL result = YES;
SEL action = [anItem action];
// FIXME should validate spa popup items; return YES if it's a native type.
if (sel_eq(action, @selector(revertDocumentToSaved:)))
{
result = ([self fileName] != nil && [self isDocumentEdited]);
}
else if (sel_eq(action, @selector(undo:)))
{
if(_undoManager == nil)
{
result = NO;
}
else
{
if([_undoManager canUndo])
{
[anItem setTitle: [_undoManager undoMenuItemTitle]];
result = YES;
}
else
{
[anItem setTitle: [_undoManager undoMenuTitleForUndoActionName: @""]];
result = NO;
}
}
}
else if (sel_eq(action, @selector(redo:)))
{
if(_undoManager == nil)
{
result = NO;
}
else
{
if([_undoManager canRedo])
{
[anItem setTitle: [_undoManager redoMenuItemTitle]];
result = YES;
}
else
{
[anItem setTitle: [_undoManager redoMenuTitleForUndoActionName: @""]];
result = NO;
}
}
}
return YES;
return result;
}
- (BOOL)validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>)anItem