0
   -(void)rightMouseDown:(NSEvent *)theEvent  
{  
    cvcont = [[CollectionViweItemSubClass alloc] init ];  
    NSMenu * m = [[NSMenu alloc] init];  
    //[cvcont openInFinder];----perfectly working------  
    [self setTarget:cvcont];  
    [m addItemWithTitle:@"show in finder" action:@selector(openInFinder) keyEquivalent:@""];// not working-----  
    [NSMenu popUpContextMenu:m withEvent:theEvent forView:self];  
}

i subclassed the button and calling a method from the class CollectionViweItemSubClass . if i calling as usually it is working. But the method was not connected via NSMenu. The below code is my method from the class CollectionViewItemSubClass

-(void)openInFinder {
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
                        stringForKey:@"filePath"];
[[NSWorkspace sharedWorkspace] selectFile:savedValue inFileViewerRootedAtPath:nil];

}

user23790
  • 563
  • 3
  • 21

0 Answers0