通过“动画”以编程方式单击 NSPushButton
我刚刚遇到了一个我已经从其他编程语言/框架中知道的问题...... 每当用户单击键盘上的某个按钮时,他都会触发与按下 GUI 中的某个按钮时相同的操作。 (有些人称这些为“快捷方式”;D)
为了给用户视觉反馈,我想以编程方式“单击”按钮,而不是调用单击按钮时调用的相同函数。
如果我将按钮设置为 IB 中的等效键,它看起来就像我想要的那样。 此处无法执行此操作,因为如果正确的文本字段具有焦点,则应启用快捷方式。
在 NSButton 或类似的方法中找不到听起来正确的方法。 我相信你们能给我一些指导!
最好,提前致谢
I just ran into a problem I already know from other programming languages/frameworks ....
Whenever the user clicks a certain button on the keyboard, he triggers the same action than when a certain button in the GUI is pressed. ( Some guys call these "shortcuts" ;D )
To give the user an optical feedback, I would like to sorta "click" the button programmatically rather than calling the same functions that get called when the button is clicked.
If I set the button as a key equivalent in IB, it looks exactly as I want to have it.
Can't do that here as the shortcut should just be enabled if the right textfields have focus.
Couldn't find a method in NSButton or similar that sounded right.
I'm sure you guys can give me some direction!
Best and thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需将
performClick:
发送到按钮即可。它将突出显示自己,将其操作发送到目标,然后取消突出显示自己。如果您确实只想手动突出显示和取消突出显示按钮,可以使用
highlight:
方法。You can just send
performClick:
to the button. It will highlight itself, send its action to its target, and then unhighlight itself.If you really want to just highlight and unhighlight the button manually, you can use the
highlight:
method.