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
If you prefer, you can attach the menu to the individual cell view or row view and build it with interface builder:
@implementation BSMotleyOutlineView
-(NSMenu *)menuForEvent:(NSEvent *)event
{
NSPoint pt = [self convertPoint:[event locationInWindow] fromView:nil];
NSInteger row = [self rowAtPoint:pt];
if (row >= 0) {
NSTableRowView* rowView = [self rowViewAtRow:row makeIfNecessary:NO];
if (rowView) {
NSInteger col = [self columnAtPoint:pt];
if (col >= 0) {
NSTableCellView* cellView = [rowView viewAtColumn:col];
NSMenu* cellMenu = cellView.menu;
if(cellMenu) {
return cellMenu;
}
}
NSMenu* rowMenu = rowView.menu;
if (rowMenu) {
return rowMenu;
}
}
}
return [super menuForEvent:event];
}
@end