Abcd Efg Abcd Efg - 4 months ago 18x
Objective-C Question

NSTableView Right Clicked Row Index

I'm looking for a way to get right-clicked row index from

but I can't find any delegate methods or class attributes for it. Any suggestion is appreciated.


While I haven't done this, I am pretty sure you can by overriding NSView's - (NSMenu*)menuForEvent:(NSEvent*)theEvent. The example in this link does a point conversion to determine the index.

    NSPoint mousePoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
   int row = [self rowAtPoint:mousePoint];
   // Produce the menu here or perform an action like selection of the row.