对于我的HTML Adobe AIR应用程序,我在启动时运行以下命令以将窗口显示为全屏:
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
然后对于激活状态我做:
window.nativeWindow.addEventListener(air.Event.ACTIVATE, function() {
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
});
因此,我们的想法是,当窗口最小化或未聚焦,然后重新聚焦时,窗口将全屏显示,并且永远不会以较小的尺寸窗口。
然而,当我点击最小化时,ACTIVATE甚至会被触发,因此窗口不能被最小化。
任何想法为什么?或者如何解决这个问题?我注意到,如果我评论该行,当我在全屏模式下最小化时,它首先使窗口“窗口化”。例如在最小化它之前,在XML文件中以800x600的设置大小...所以想知道问题出在哪里?它实际上通过执行该步骤来激活窗口以进入最小化模式。
确保应用程序从最小化状态恢复后进入全屏的任何其他建议?
第二个问题是在使用以下窗口时使窗口可见且不可见:
window.nativeWindow.addEventListener(air.Event.ACTIVATE, function() {
window.nativeWindow.visible = true;
});
window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {
window.nativeWindow.visible = false;
});
这个想法是,当应用程序处于全屏状态时,如果用户远离它,或者最小化窗口,它应该隐藏它以便在其他窗口后面看不到它(如Adobe AIR使用的那样) Flash Player实现全屏)
这里的问题是,当我离开窗户后使ALT-Tab或CMD-Tab到窗口时,窗口永远不会再次可见。在最小化或最大化窗口时它也不会改变可见性状态,但是DOES会激活激活和停用事件。不知道这是因为最小化的Mac OS X动画?
关于如何解决这两个问题的任何想法?
是否有可见的替代品可隐藏或显示窗口? CSS显示无选项无法使用!
为什么当我最小化导致全屏无限循环的窗口时会触发activate事件?
好的,所以我发布这个作为Windows 7上的当前工作解决方案(不回答只是显示当前进度的问题)基于Paul Facklam在下面通过检查displayState normal发布的内容而不是最小化并将其与一些附加功能混合以使窗口填充屏幕边界并使其居中。
function centerWindow(instance){
//default bounds of nativeWindow
var applicationBounds = instance.nativeWindow.bounds;
//determine which screen we're located on
var screens = air.Screen.getScreensForRectangle(instance.nativeWindow.bounds);
var screenBounds = (screens.length > 0) ? screens[0].visibleBounds : air.Screen.mainScreen.visibleBounds;
//get initial position
x = (screenBounds.width - applicationBounds.width) / 2;
y = (screenBounds.height - applicationBounds.height) / 2;
//adjust for offset x or offset y (multi monitors)
x = screenBounds.x + x;
y = screenBounds.y + y;
instance.nativeWindow.x = x;
instance.nativeWindow.y = y;
}
function resizeWindow(instance) {
//default bounds of nativeWindow
var applicationBounds = instance.nativeWindow.bounds;
//determine which screen we're located on
var screens = air.Screen.getScreensForRectangle(instance.nativeWindow.bounds);
var screenBounds = (screens.length > 0) ? screens[0].visibleBounds : air.Screen.mainScreen.visibleBounds;
//set the window widths and height to window (this so the aero peak doesn't show a small window)
instance.nativeWindow.width = screenBounds.width;
instance.nativeWindow.height = screenBounds.height;
//then center the window
centerWindow(instance);
}
$(document).ready(function() {
//resize the window on load
resizeWindow(window);
//make window fullscreen
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
//make sure it's visible (if not already)
window.nativeWindow.visible = true;
//if window is activated and display is normal i.e. NOT fullscreen, make it fullscreen
window.nativeWindow.addEventListener(air.Event.ACTIVATE, function() {
if(window.nativeWindow.displayState == 'normal') {
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
});
//if window is unfocused then minimize to the taskbar or dock
window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {
window.nativeWindow.minimize(); // minimizes the window
});
});
还没有机会在Mac OS X上测试它,但似乎OS X确实以不同的方式对待ACTIVATE和DEACTIVATE事件......基于我之前尝试过的实验。
可以在Mac OS X上确认此问题!并且可以在Windows上正常运行。因此,看起来停靠窗口的方式会导致事件以不正常的方式触发,从而导致循环等。
其他人在Mac OS X for AIR上遇到过这些事件的问题吗?
更新:我想知道是否使用:
if(event.afterDisplayState == air.NativeWindowDisplayState.MINIMIZED)
将有助于解决OS X问题(今晚我将进行测试)。
答案 0 :(得分:0)
试试这个:
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
window.nativeWindow.addEventListener(air.Event.ACTIVATE, function() {
if(window.nativeWindow.displayState === air.NativeWindowDisplayState.MINIMIZED) {
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
});
window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {
window.nativeWindow.minimize();
});
答案 1 :(得分:0)
解决OS X问题的一种可能解决方案是执行以下操作:
if (air.Capabilities.os.indexOf("Mac OS") > -1) {
var firstRun = false;
window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {
if(firstRun) {
air.trace('DEACTIVATE');
} else {
firstRun = true;
}
});
} else {
window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {
air.trace('DEACTIVATE');
});
}
因此,如果正在使用OS X,它基本上忽略了DEACTIVATE的奇怪的第一次调用......然后像正常那样处理它。虽然这感觉像是一个可怕的丑陋黑客!