寻找一个可可方法来模拟没有事件作为参数的按钮按下

发布于 2024-08-16 03:34:37 字数 209 浏览 3 评论 0原文

我需要以编程方式模拟 Cocoa 按钮上的按钮按下,我试图在 cocotron 上执行此操作,不幸的是它没有 NSEvent 方法: mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:Pressure: 实施的。是否有办法以编程方式模拟按钮按下而无需创建事件?

I need to simulate a button press on my Cocoa button programatically and I am trying to do this on cocotron which unfortunately does not have the NSEvent method: mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:
implemented. Is there anyway to programatically simulate a button press without having to create an event?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒人说梦 2024-08-23 03:34:37

当您寻找某些东西时,不要忘记查看超类。所有 NSControl,包括所有 NSButton,都会响应 performClick: 消息

也就是说,模拟按钮按下真的适合您吗?如果您只想完成某件事,通常最好直接告诉控制器去做。

Don't forget to look in superclasses when you're looking for something. All NSControls, including all NSButtons, respond to a performClick: message.

That said, is it really appropriate for you to simulate a button press? If you just want something done, it's generally better to directly tell the controller to do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文