How do you add the ability to right click on a row in an NSOutlineView so you can say delete an object or some other activity. (ie Like when you right click on a folder in t
Much later than the OP question, but for others like me wondering, here is my solution. It also needs subclassing NSOutlineView, which is not encouraged by Apple doc, anyway…
Rather than override menuForEvent: I override rightMouseDown:
- (void)rightMouseDown:(NSEvent *)event {
NSPoint pt = [self convertPoint:[event locationInWindow] fromView:nil];
NSInteger row = [self rowAtPoint:pt];
id item = [self itemAtRow:row];
NSMenu *menu;
//set the menu to one you have defined either in code or IB through outlets
self.menu = menu;
[super rightMouseDown:event];
}
This has the advantage of keeping delegate calls to update the menu thereafter and also keeps row outlining on right click.