Abcd Efg Abcd Efg - 2 years ago 185
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.

Answer Source

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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download