在 Mac 上的 AIR 应用程序中检测不同的退出选项 [英] Detecting different quit options in AIR application on Mac

查看:21
本文介绍了在 Mac 上的 AIR 应用程序中检测不同的退出选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Mac 上运行的 AIR 应用程序,我想要在有人关闭"应用程序(例如点击红色的x"按钮或 cmd-w)时隐藏窗口的行为.但是,如果有人点击 cmd-q 或从停靠栏上下文菜单或顶级菜单中选择退出",我希望应用真正关闭.

I have an AIR application running on a Mac and I want to have the behavior of hiding the window when someone "closes" the app (e.g. hits the red "x" button or cmd-w). However, if someone hits cmd-q or chooses "Quit" from the dock context menu or top level menu, I want the app to actually close.

我可以在应用程序发送的关闭"事件上防止默认,但是,这会导致所有关闭"方法只是隐藏窗口.那时某人关闭应用程序的唯一方法是 ForceQuit(或通过我提供的单独界面,例如停靠栏图标上的上下文菜单选项).

I can preventDefault on the "closing" event sent by the application, however, this causes all "close" methods to just hide the window. The only way for someone to close the application at that point is ForceQuit (or through a separate interface I provide, like a context menu option on the dock icon).

我也尝试过手动捕获 cmd-q keyDown 事件,但它没有被发送.此外,当人们尝试使用菜单选项退出应用程序时,这也无济于事.

I have also tried capturing the cmd-q keyDown event manually, but it doesn't get sent. Also, this wouldn't help for the case when people try to quit the app using the menu options.

此外,如果我在关闭方法上防止默认,它会导致我的应用程序立即取消关闭过程(这是一种糟糕的用户体验).

Furthermore, if I preventDefault on the closing method, it causes my application to cancel a shut down process immediately (which is a terrible user experience).

有没有办法检测关闭 AIR 应用程序的不同方法?我希望能够分辨出这些关闭方法之间的区别并做出适当的反应.

Is there a way to detect different methods of closing an AIR application? I want to be able to tell the difference between these closing methods and react to the appropriately.

推荐答案

尝试这个作为结束,据我所知,框架中存在/是一个错误,因此如果您包含 AIR 更新程序,它会破坏 cmd-q 支持,线程曾经在这里:http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=670&threadid=1373568

Try this for the closing, from what I understand there was / is a bug in the framework so that if you include the AIR updater it breaks cmd-q support, the thread used to be here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=670&threadid=1373568

这可能适用于您的情况,也可能不适用.

This may or may not be applicable to your situation.

NativeApplication.nativeApplication.addEventListener(Event.EXITING, 
        function(e:Event):void {
            var opened:Array = NativeApplication.nativeApplication.openedWindows;
            for (var i:int = 0; i < opened.length; i ++) {
                opened[i].close();
            }
    });

这篇关于在 Mac 上的 AIR 应用程序中检测不同的退出选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆