Objective-C:聆听键盘快捷键并对其进行操作 [英] Objective-C: Listen to keyboard shortcuts and act on them

查看:91
本文介绍了Objective-C:聆听键盘快捷键并对其进行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Mac OS X开发一个应用程序,我需要听键盘快捷键输入,以便可以对它们进行操作.

I am developing an app for Mac OS X and I need to listen to keyboard shortcut inputs so I can act on them.

例如:

  • 键和键在表视图上上下移动.
  • + 删除项目.
  • + + N 创建一个新项目.
  • Up and down keys move up and down on a table view.
  • + drops an item.
  • + + N creates a new item.

不应仅限于焦点控件上的事件.

It shouldn't be restricted to events on the focused control.

有什么想法吗?

谢谢.

推荐答案

看看

Have a look at the Cocoa Event-Handling Guide. There are a few places you can intercept events before they get to the key view. You can intercept all events in the application by overriding -[NSApplication sendEvent:], or you can intercept events at a per-window level by overriding-[NSWindow sendEvent:].

这篇关于Objective-C:聆听键盘快捷键并对其进行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆