Cocoa 响应程序链和上下文菜单单击
我有一个基于视图的 NSTableView 填充的自定义 NSTabelCellView 子类,它们是视图层次结构中最低的对象(无子视图)。我重写了 mouseDown: 方法来拦截鼠标点击。当用户左键单击单元格视图时,这很好,但是,当他们右键单击单元格视图时,此方法永远不会被调用,并且以某种方式,与表视图关联的菜单仍然显示,即使单元格视图应该是第一个回应的对象。有谁知道这是为什么?如何拦截视图中的右键单击?
I have a view-based NSTableView
populated custom NSTabelCellView
subclass, which are the lowest objects in the view hierarchy (no subviews). I overrode the mouseDown:
method to intercept mouse clicks. This fine when user left-click the cell view, however, when they right click the cell view this method somehow never gets called, and somehow the menu associated with the table view still shows up, even though the cell view is suppose to be the first object to respond. Does anyone know why this is? How can I intercept right clicks in a view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有 为三个主要鼠标按钮中的每一个提供不同的方法组。
无论如何,您可能不想在如此低的级别上实现这一点。如果整个表格视图的上下文菜单都相同,则只需设置其
menu
即可。如果您希望每个单元格的设置都不同,您可以尝试设置单元格视图的菜单
。There are different groups of methods for each of the three main mouse buttons.
Anyway, you probably don't want to implement this at such a low level. If the context menu is the same throughout the table view, just set its
menu
. If you want it to differ for each cell, you might try setting the cell view'smenu
.