你能获取NativeWindow最小化事件吗?
在 AIR 中使用 NativeWindow
时,每次窗口最小化/取消最小化时是否都能收到事件?我尝试连接 DisplayStateChanged
但当窗口最小化时它不会触发。你知道如何获得这样的事件吗?
我使用的是 32 位 Windows 7,并且运行的是 AIR 3.5。
这是初始化代码:
var init:NativeWindowInitOptions = new NativeWindowInitOptions();
init.maximizable = true;
init.resizable = true;
init.type = NativeWindowType.NORMAL;
init.minimizable = true;
window = new NativeWindow(init);
window.alwaysInFront = true;
window.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, dispChange, false, 0, true);
这是处理程序:
private function dispChange(e:NativeWindowDisplayStateEvent):void {
// if minimized / un-minimized
if (e.beforeDisplayState == NativeWindowDisplayState.NORMAL && e.afterDisplayState == NativeWindowDisplayState.MINIMIZED) {
trace("MINIMIZED!");
}else if (e.beforeDisplayState == NativeWindowDisplayState.MINIMIZED && e.afterDisplayState == NativeWindowDisplayState.NORMAL) {
trace("Un-MINIMIZED!");
}
}
When working with NativeWindow
's in AIR, can you get an event everytime the window is minimized / unminimized? I tried hooking up with DisplayStateChanged
but its not firing when the window is minimized. Do you know how to get such an event?
I'm on Windows 7, 32-bit, and I'm running AIR 3.5.
This is the init code:
var init:NativeWindowInitOptions = new NativeWindowInitOptions();
init.maximizable = true;
init.resizable = true;
init.type = NativeWindowType.NORMAL;
init.minimizable = true;
window = new NativeWindow(init);
window.alwaysInFront = true;
window.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, dispChange, false, 0, true);
And this is the handler:
private function dispChange(e:NativeWindowDisplayStateEvent):void {
// if minimized / un-minimized
if (e.beforeDisplayState == NativeWindowDisplayState.NORMAL && e.afterDisplayState == NativeWindowDisplayState.MINIMIZED) {
trace("MINIMIZED!");
}else if (e.beforeDisplayState == NativeWindowDisplayState.MINIMIZED && e.afterDisplayState == NativeWindowDisplayState.NORMAL) {
trace("Un-MINIMIZED!");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下内容在使用 AIR 3.3 / Flash Player 11.3 的 Windows 7 64 位上运行良好。
the following works fine on Windows 7 64-bit with AIR 3.3 / Flash Player 11.3.
窗口实际上是否可以最小化(检查
window.minimizing
,而不仅仅是init
设置)?我还想知道以下结果:
我还想知道上面“弱引用”评论的结果。这会影响垃圾收集,因此测试总是一件好事。
Is the window actually minimizable (check
window.minimizable
, not just theinit
setting)?I would also like to know the results of:
I would also want to know the results of the 'weak reference' comment above. This affects garbage collection, so is always a good thing to test.
我能得到的最接近最小化事件的是激活事件。每当用户在应用程序外部单击时,该窗口就会停用。然后,您可以使用最小化()自动最小化窗口。但是,当用户最小化窗口/切换到另一个窗口时,也会调用 deactivated 事件。当用户切换回来时,您会接到激活电话。
The closest thing I could get to a minimized event was the activate events. Whenever the user clicks outside the app, that window gets deactivated. You can then minimize the window automatically using minimize(). But the deactivated event is also called when the user minimizes the window / switches to another. And when the user switches back you get a call to activate.
我收到最小化/取消最小化的事件。我正在构建一个 AIR 3.5 应用程序。
I'm getting events for minimize / unminimize. I'm building an AIR 3.5 app.