寻找一个可可方法来模拟没有事件作为参数的按钮按下
我需要以编程方式模拟 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您寻找某些东西时,不要忘记查看超类。所有 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.