本文介绍了如何检测可可的右键和左键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在鼠标的右键和左键上创建一个操作。点击可以在NSTableViewCell,NSView等(就像当我们右键点击窗口它给出一个弹出窗口)。有没有任何API来做这样的任务?如果没有,任何其他方式。

I want to create a action on right and left click of mouse. Click may be on NSTableViewCell, NSView, etc (Like when we right click on window it gives a pop-up ) . Is there any API to do such task? If no, any other way .Thank you in advance for helping me.

推荐答案

您必须覆写 NSResponder 方法例如:

- (void) mouseDown: (NSEvent*) theEvent;
- (void) rightMouseDown: (NSEvent*) theEvent;

参考:。

更新:as如下所述, NSView NSTableView 从NSResponder继承这些方法。

Update: as mentioned below, NSView and NSTableView inherits these methods from NSResponder.

这篇关于如何检测可可的右键和左键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:08