mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-20 20:26:57 +00:00
Implement undo: and redo: responder actions in NSWindow as on Mac OS X.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27218 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7f9939a624
commit
fe56e4959d
3 changed files with 85 additions and 50 deletions
|
@ -50,6 +50,7 @@
|
|||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSUndoManager.h>
|
||||
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSButton.h"
|
||||
|
@ -2979,6 +2980,16 @@ resetCursorRectsForView(NSView *theView)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) undo: (id)sender
|
||||
{
|
||||
[[self undoManager] undo];
|
||||
}
|
||||
|
||||
- (void) redo: (id)sender
|
||||
{
|
||||
[[self undoManager] redo];
|
||||
}
|
||||
|
||||
/**
|
||||
If YES, then the window is released when the close method is called.
|
||||
*/
|
||||
|
@ -4753,6 +4764,73 @@ current key view.<br />
|
|||
_f.displays_when_screen_profile_changes = flag;
|
||||
}
|
||||
|
||||
/*
|
||||
* Menu item validation
|
||||
*/
|
||||
|
||||
- (BOOL)validateMenuItem: (NSMenuItem *)anItem
|
||||
{
|
||||
BOOL result = YES;
|
||||
SEL action = [anItem action];
|
||||
|
||||
if (sel_eq(action, @selector(performClose:)))
|
||||
{
|
||||
result = ([self styleMask] & NSClosableWindowMask) ? YES : NO;
|
||||
}
|
||||
else if (sel_eq(action, @selector(performMiniaturize:)))
|
||||
{
|
||||
result = ([self styleMask] & NSMiniaturizableWindowMask) ? YES : NO;
|
||||
}
|
||||
else if (sel_eq(action, @selector(performZoom:)))
|
||||
{
|
||||
result = ([self styleMask] & NSResizableWindowMask) ? YES : NO;
|
||||
}
|
||||
else if (sel_eq(action, @selector(undo:)))
|
||||
{
|
||||
NSUndoManager *undo = [self undoManager];
|
||||
if (undo == nil)
|
||||
{
|
||||
result = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([undo canUndo])
|
||||
{
|
||||
[anItem setTitle: [undo undoMenuItemTitle]];
|
||||
result = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
[anItem setTitle: [undo undoMenuTitleForUndoActionName: @""]];
|
||||
result = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sel_eq(action, @selector(redo:)))
|
||||
{
|
||||
NSUndoManager *undo = [self undoManager];
|
||||
if (undo == nil)
|
||||
{
|
||||
result = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([undo canRedo])
|
||||
{
|
||||
[anItem setTitle: [undo redoMenuItemTitle]];
|
||||
result = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
[anItem setTitle: [undo redoMenuTitleForUndoActionName: @""]];
|
||||
result = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assigning a delegate
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue