NSTableView右键行索引 [英] NSTableView Right Clicked Row Index
本文介绍了NSTableView右键行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种方法从 NSTableView
获得右键单击的行索引,但我找不到任何委托方法或类属性。任何建议是赞赏。
I'm looking for a way to get right-clicked row index from NSTableView
but I can't find any delegate methods or class attributes for it. Any suggestion is appreciated.
推荐答案
虽然我还没有这样做,我相信你可以通过重写 NSView
'
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
。 此链接中的示例执行点转换以确定索引。
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.
-(NSMenu*)menuForEvent:(NSEvent*)theEvent
{
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.
}
这篇关于NSTableView右键行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文