osx – 如何检测到按下Shift键?

osx – 如何检测到按下Shift键?,第1张

概述我有一个NSView子类,我希望它在用户按下⇧Shift键时作出反应.但是,当按下修改键时,不会调用[NSView keyDown:](我当前覆盖). 按Shift键时如何通知? 从 Cocoa事件处理指南: The flagsChanged: method can be useful for detecting the pressing of modifier keys without any 我有一个NSVIEw子类,我希望它在用户按下⇧Shift键时作出反应.但是,当按下修改键时,不会调用[NSVIEw keyDown:](我当前覆盖).

按Shift键时如何通知?

解决方法 从 Cocoa事件处理指南:

The flagsChanged: method can be useful for detecting the pressing of modifIEr keys without any other key being pressed simultaneously. For example,if the user presses the Option key by itself,your responder object can detect this in its implementation of flagsChanged:.

更多细节可以找到here.

NSResponder的文档还说明如下:

flagsChanged:

Informs the receiver that the user has pressed or released a modifIEr key (Shift,Control,and so on).

— (voID)flagsChanged:(NSEvent *)theEvent

总结

以上是内存溢出为你收集整理的osx – 如何检测到按下Shift键?全部内容,希望文章能够帮你解决osx – 如何检测到按下Shift键?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1019290.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存