Permalink
Browse files

Snippets deactivated when no document is loaded

  • Loading branch information...
1 parent 1af6a18 commit e0611d1727e11a26104627609f26aa6d44376afb @jfmoy committed Mar 24, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 Classes/FRAToolsMenuController.m
@@ -27,6 +27,8 @@
#import "FRAExtraInterfaceController.h"
#import "FRATextView.h"
+#define SNIPPET_TAG 100
+
@implementation FRAToolsMenuController
static id sharedInstance = nil;
@@ -172,6 +174,7 @@ - (void)buildInsertSnippetMenu
[subMenuItem setKeyEquivalentModifierMask:[[snippet valueForKey:@"shortcutModifier"] integerValue]];
[subMenuItem setTarget:self];
[subMenuItem setRepresentedObject:snippet];
+ [subMenuItem setTag:SNIPPET_TAG]; // Used for validation
[subMenu insertItem:subMenuItem atIndex:0];
}
@@ -360,7 +363,11 @@ - (BOOL)validateMenuItem:(NSMenuItem *)anItem
if ([[[FRACommandsController sharedInstance] commandsWindow] isVisible] == NO) {
enableMenuItem = NO;
}
- }
+ } else if (tag == SNIPPET_TAG) {
+ if (FRACurrentTextView == nil) {
+ enableMenuItem = NO;
+ }
+ }
return enableMenuItem;
}

0 comments on commit e0611d1

Please sign in to comment.