【发布时间】:2017-01-11 02:21:45
【问题描述】:
我在选中多个行时在控制上单击“控制上的上下文敏感菜单”时遇到问题。 Its working fine when a single row is selected and then control clicked on it. 我的实现方式如下所示:
-(void)doSingleClick
{
NSLog(@"single clicked");
if([[NSApp currentEvent] modifierFlags] & NSControlKeyMask)
{
NSLog(@"control clicked.......");
[NSMenu popUpContextMenu:[self showContextMenu] withEvent:[NSApp currentEvent] forView:tableView];
return;
}
}
并且 showContextMenu 函数返回一个 NSMenu 对象。
我这样做是因为我的表格视图由于某种奇怪的原因无法识别 mouseDown 或 mouseUp 或 menuForEvent 事件。
the problem with the above code segment is, when multiple rows are selected and control clicked, it does not recognize the control click and does not go into that loop and hence not displaying the context menu.
请建议我实现这一目标的机制。
谢谢
【问题讨论】:
-
-(void)doSingleClick是如何被调用的?这可能是问题的原因。 -
[tableView setAction:@selector(doSingleClick)];在 awakeFromNib 所以只要有一个点击它就会被调用
标签: cocoa contextmenu