diff options
author | nyamatongwe <nyamatongwe@gmail.com> | 2013-04-24 19:33:49 +1000 |
---|---|---|
committer | nyamatongwe <nyamatongwe@gmail.com> | 2013-04-24 19:33:49 +1000 |
commit | 1b4e97f8b5e628af033612e12e647718f8d5ee84 (patch) | |
tree | 0a20d70d2982947fbfa1d957518e0d91dd2f7c61 /cocoa | |
parent | 440e6883c5563a04ba46de3dbe4949f20cde5124 (diff) | |
download | scintilla-mirror-1b4e97f8b5e628af033612e12e647718f8d5ee84.tar.gz |
Feature: [feature-requests:#987]. Cocoa user interface validation.
Diffstat (limited to 'cocoa')
-rw-r--r-- | cocoa/ScintillaView.h | 2 | ||||
-rw-r--r-- | cocoa/ScintillaView.mm | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h index 996501788..356c34adb 100644 --- a/cocoa/ScintillaView.h +++ b/cocoa/ScintillaView.h @@ -48,7 +48,7 @@ extern NSString *SCIUpdateUINotification; * InnerView is the Cocoa interface to the Scintilla backend. It handles text input and * provides a canvas for painting the output. */ -@interface InnerView : NSView <NSTextInputClient> +@interface InnerView : NSView <NSTextInputClient, NSUserInterfaceValidations> { @private ScintillaView* mOwner; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index a23a4b8b0..7f6b4991e 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -787,6 +787,28 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) return mOwner.backend->CanRedo(); } +- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>) anItem +{ + SEL action = [anItem action]; + if (action==@selector(undo:)) { + return [self canUndo]; + } + else if (action==@selector(redo:)) { + return [self canRedo]; + } + else if (action==@selector(cut:) || action==@selector(copy:) || action==@selector(clear:)) { + return mOwner.backend->HasSelection(); + } + else if (action==@selector(paste:)) { + return mOwner.backend->CanPaste(); + } + return YES; +} + +- (void) clear: (id) sender +{ + [self deleteBackward:sender]; +} - (BOOL) isEditable { |