Pregunta

I encontró este archivo en código de Google con la función:

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;
    }
}

Las partes de él que me faltan son:

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

Pero no estoy encontrando lo que define dónde está el Ci. Cualquier idea de lo que puede ser? O cualquier otra idea de cómo configurar una ventana siempre encima? (Esa solución "sólo por las ventanas de" No se ajusta a mí).

- Actualización

Estoy leyendo acerca de la nsIWindowMediator , que tiene algunos métodos para manejar el orden Z ventana . Pero está diciendo que los métodos deben ser usados ??de C ++, no javascript. Eso significa que el código debe ser utilizado desde XPCOM componentes (I debería XPCOM como componente para abrir la ventana)? ¿Hay alguien que ya lo utilizó pudo confirmar?

Todavía estoy leyendo de todos modos.

- Actualización

He intentado la nsIWindowMediator (con un componente XPCOM) pero simplemente no hace nada cuando me puse el nivel Z.

Todavía buscar una manera de poner las tiendas de comida en la parte superior de la ventana ..

- intento con 'alwaysraised':

test.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>

no funcionó.

- intento con 'zlevel':

test.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>

no funcionó. Nither con alwaysraised setted, o la adición de un zlevel superior o inferior a la test.xul (con top.xul zlevel = "6")

¿Fue útil?

Solución

Encontrados:. Basta con abrir usando openDialog, y será siempre en la parte superior

Ejemplo:

<?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>

Otros consejos

Si siempre desea que la ventana para estar en la parte superior, a continuación, la forma más fácil es usar la bandera alwaysraised cromo al abrir la ventana.

Si no se llega a abrir la ventana del mismo, la forma en la segunda más sencilla es utilizar <window zlevel="6"> en su XUL. Incluso puede persistir la zlevel; ventana de Ayuda de Firefox hace esto, utilizando una opción del menú contextual para cambiar el zLevel.

Por cierto, Ci es una abreviatura común para Components.interfaces ya que la escritura (por ejemplo) Components.interfaces.nsIXULWindow.rasiedZ es difícil de hacer en las líneas de 80 caracteres.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top