应用程序退出事件
我正在开发可可应用程序。我的应用程序最初显示一个弹出表。我需要知道当我们尝试通过右键单击并选择停靠栏图标上的“退出”来退出应用程序时会触发哪个事件,因为由于弹出表而无法退出应用程序。我该如何解决这个问题?
I am developing an application in cocoa. My application shows a pop up sheet initially. I need to know which event is fired when we try to exit the application by right clicking and selecting "exit" on the icon in dock, because I can't exit the application because of the popup sheet. How can I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当在 Dock 菜单中选择“退出”项时,您的应用会收到
quit
Apple 事件。如果您想拦截此事件,则需要为此事件安装自定义 Apple 事件处理程序。请注意,工作表在工作表被关闭之前阻止应用程序终止是正常的,因此,如果您更改此行为,您的应用程序的工作方式将与其他应用程序不同。以下是如何在应用程序委托中覆盖
quit
Apple 事件的默认处理程序的简单示例:Your app is sent a
quit
Apple Event when the Quit item is selected in the Dock menu. If you want to intercept this you will need to install a custom Apple Event Handler for this event. Note that it's normal for sheets to prevent application termination until the sheet is dismissed, so if you change this behavior your app will work differently to other applications.Here is a simple example of how to override the default handler for
quit
Apple Events in your application delegate: