gpt4 book ai didi

javascript - 如何将 Xul 窗口放置为 "Always On Top"?

转载 作者:行者123 更新时间:2023-11-29 10:53:58 26 4
gpt4 key购买 nike

我找到了 this file在具有以下功能的谷歌代码中:

function SetAlwaysOnTop() {
var chkTop = document.getElementById("itmAlwaysOnTop");
var xulWin = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem)
.treeOwner.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow);
if(chkTop.getAttribute("checked") == "true") {
xulWin.zLevel = xulWin.raisedZ;
} else {
xulWin.zLevel = xulWin.normalZ;
}
}

我需要的部分是:

var xulWin = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem)
.treeOwner.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow);
xulWin.zLevel = xulWin.raisedZ;

但我没有找到 Ci 在哪里定义的内容。知道它会是什么吗?或者关于如何始终在顶部设置窗口的任何其他想法? (“仅适用于 Windows”的解决方案不适合我)。

--更新

我正在阅读 nsIWindowMediator ,它有一些方法来处理窗口 Z 顺序。但它说这些方法应该从 c++ 中使用,而不是 javascript。那意味着代码应该使用来自 XPCOM 组件(我应该作为 XPCOM 组件来打开窗口)?有没有用过的可以确认一下?

反正我还在读书。

--更新

我已经尝试过 nsIWindowMediator(带有 XPCOM 组件)但是当我设置 Z 级别时它什么都不做。

仍在寻找将窗口放在顶部的方法..

--尝试使用'alwaysraised':

测试.xul:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300"
onload="open('top.xul','GreenfoxChannelWindow','chrome, alwaysraised');"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<label value="MAIN WINDOW"/>

</window>

top.xul:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<label value="ON TOP"/>

</window>

没用。

--尝试使用“zlevel”:

测试.xul:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300"
onload="open('top.xul','GreenfoxChannelWindow','chrome');"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<label value="MAIN WINDOW"/>

</window>

top.xul:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300" zlevel="6"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<label value="ON TOP"/>

</window>

没用。无论是 alwaysraised 设置,还是向 test.xul 添加更高或更低的 zlevel(top.xul zlevel="6")

最佳答案

发现:直接用openDialog打开,会一直在最上面

例如:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300"
onload="openDialog('top.xul','TopWindow','chrome');"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<label value="MAIN WINDOW"/>

</window>

top.xul:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<label value="ON TOP" />

</window>

关于javascript - 如何将 Xul 窗口放置为 "Always On Top"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4335286/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com