To show a context menu on right click of an NSOutlineView you have to subclass it and override:
- (NSMenu *)menuForEvent:(NSEvent *)theEvent {
NSPoint pt = [self convertPoint:[theEvent locationInWindow] fromView:nil];
id item = [self itemAtRow: [self rowAtPoint:pt]];
// Only the delegate knows how to create a menu based on the item
return [self createMenuFor: item];
}
So what is the proper way to get the delegate to create the menu here and handle the menu actions?
EDIT - So the subclass doesn't know how to create the menu so I just did this. Is it ok? I just didn't see any example code for how to communicate with the delegate online.
return [[self delegate] createMenuForItem:item];
And obviously defined a method in my outline view delegate to return an NSMenu.