title: Conditional right click items in macos - finder
body: <p>I'm trying to add right click items with NSMenuItem tools with Finder Inject. I need to change the items according to the path of the clicked file/folder. But it seems that, with finder inject, the menu items are generated before right-click.</p>
  
  <p>In other words, I can't edit the MenuItems regarding on a condition that checks the path of the right-clicked file. Any ideas?</p>
  
  <p>I've tried </p>
  
  <pre><code>-(NSMenuItem *)createMenuItem {     
      // I need to catch the path of the clicked item here.    
      NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"ITEM TITLE" action:@selector(myMethodClicked:) keyEquivalent:@""];
      [menuItem setTarget:self];     
      return menuItem;
  }
  </code></pre>
  
  <p>I can get path of the clicked file with the method below, see the line:</p>
  
  <pre><code>NSArray *selectedFiles = [[ILFinderMenu sharedInstance] selectedItems];
  </code></pre>
  
  <p>But I need it before the menuItems are added. Whole function is also added below.</p>
  
  <pre><code>- (void)myMethodClicked:(id)sender {
      NSMenuItem *item = (NSMenuItem *)sender;
      NSMenu *submenu = [item submenu];
      
      NSArray *selectedFiles = [[ILFinderMenu sharedInstance] selectedItems];
      NSString *selectedFilePath = [selectedFiles objectAtIndex:0];
      NSString *appPath = @"/eclipse/";
              
      if ([selectedFilePath rangeOfString:appPath].location != NSNotFound) {
          // disable backup
          NSMenuItem *backupMenuItem = [submenu itemAtIndex:1];
          [backupMenuItem setEnabled:NO];
          
          // enable share
          NSMenuItem *shareItem = [submenu itemAtIndex:0];
          [shareItem setEnabled:YES];
      } else {            
          // disable share
          NSMenuItem *backupMenuItem = [submenu itemAtIndex:0];
          [backupMenuItem setEnabled:NO];
          
          // enable backup
          NSMenuItem *shareItem = [submenu itemAtIndex:1];
          [shareItem setEnabled:YES];
      }
  }
  </code></pre>