Flex - Air 原生窗口 closeHandler 不起作用?
在我的 Flex (Flash Builder 4) Air 应用程序中,我有一个 Spark 窗口,并将 close="" 事件处理程序(也尝试了“关闭”事件)设置为弹出警报确认是否要关闭的方法窗户。
这在我正常的基于浏览器的应用程序中作为 TitleWindow 工作得很好,但现在它是一个带有本机 Spark 窗口的 Air 应用程序,它不起作用。我从来没有看到警报对话框,如果我调试跟踪,它实际上会进入我的关闭处理程序方法,但在视觉上我可以看到窗口已经从屏幕上消失了。
在 AIR 应用程序中,如何在单击“x”关闭窗口时添加确认对话框?
In my Flex (Flash Builder 4) Air application, I have a spark window , and have set the close="" event handler (also tried the 'closing' event) to a method that pops up an alert confirming if they want to close the window.
This worked fine in my normal browser based app as a TitleWindow, but now that it's an Air app with a native spark window, it's not working. I never see the alert dialog, and if I debug trace, it does in fact go in to my close handler method, but visually I can see the window is already gone from the screen.
In an AIR application, how do you add a confirmation dialog for when they click the "x" to close the window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从文档看来,关闭就是执行此操作的方法,从以下文档复制:
关闭事件
事件对象类型:flash.events.Event
属性 Event.type = flash.events.Event.CLOSING
运行时版本:AIR 1.0
在窗口即将关闭之前由此 NativeWindow 对象调度。可以取消此事件以防止窗口关闭。
Event.CLOSING 常量定义关闭事件对象的 type 属性的值。
该事件具有以下属性:
属性值
气泡假
可取消真;取消此事件对象将停止关闭操作。
currentTarget 正在使用事件侦听器主动处理 Event 对象的对象。
target 要关闭连接的对象。
摘自:
http://help.adobe .com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#event:looking
它说关闭确实在窗口关闭之后发生,但关闭应该在之前,并且可以取消以停止这窗口关闭。
From the docs it looks like closing would be the one to do it, copied from the docs below:
closing Event
Event Object Type: flash.events.Event
property Event.type = flash.events.Event.CLOSING
Runtime Versions: AIR 1.0
Dispatched by this NativeWindow object immediately before the window is to be closed. This event can be canceled to prevent the window from being closed.
The Event.CLOSING constant defines the value of the type property of a closing event object.
This event has the following properties:
Property Value
bubbles false
cancelable true; canceling this event object stops the close operation.
currentTarget The object that is actively processing the Event object with an event listener.
target The object whose connection is to be closed.
Taken from:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#event:closing
It says close does happen after the window is closed but closing should be right before and can be cancelled to stop the window from closing.