As for me the best place for menu logic is delegate, so you can subclass NSTableView
and make something like this (in this example there is NSOutlineView
but it doesn't meter)
@protocol MYOutlineViewDelegate;
@interface MYOutlineView : NSOutlineView
@property (assign) id<MYOutlineViewDelegate> delegate;
@end
@protocol MYOutlineViewDelegate <NSOutlineViewDelegate>
- (NSMenu *)outlineView:(NSOutlineView *)outlineView menuForItem:(id)item;
@end
@implementation MYOutlineView
@dynamic delegate;
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
NSMenu* menu = nil;
NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
id item = [self itemAtRow:[self rowAtPoint:point]];
if([self.delegate respondsToSelector:@selector(outlineView:menuForItem:)]) {
menu = [self.delegate outlineView:self menuForItem:item];
}
return menu;
}
@end