Thunderbird 60+的XUL窗口事件

时间:2019-03-04 07:53:37

标签: javascript firefox-addon xul thunderbird thunderbird-addon

我正在尝试使用JavaScript(在 Thunderbird 插件中)的另一个window打开window。我能够达到预期的结果,但是问题是我无法在之前或之后动态修改窗口的内容。同样,window对象似乎根本不会触发任何事件...

这是我的.js函数,首先被调用:

function displayMessageUpdated(message, callback) {
    loadLabel(message);
}

function loadLabel(message) {
    var height = 30;
    var width = 150;
    var centerX = (window.innerWidth / 2) + height;
    var centerY = (window.innerHeight / 2) + height;

    function changeText() {
        //code will never enter here
        var displayer = $("#message-text");
        displayer.val(message);
    }
    var windowC = $("#message");
    windowC.on("click", changeText);

    var dialog = window.openDialog("chrome://myfirstext/content/dialog.xul", "message", "chrome, modal, width = " + width + " ,height = " + height + " ,screenX = " + centerX + " ,screenY = " + centerY, message);
}

这是打开的我的.xul文件:

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

<!DOCTYPE overlay>
<!-- <?xul-overlay href="chrome://lightning/content/lightning-item-toolbar.xul"?> -->

<body>
    <overlay id="dialog-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"/>
    <script type="application/javascript" src="chrome://myfirstext/content/dialog.js"/>

      <window 
        id="message"
        title="Message"
        orient="vertical"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

        <textbox id="message-text" disabled="true" />
      </window>

    </overlay>
</body>

我真的不明白我应该如何以编程方式更改.xul。确切地说,我需要更改<textbox>的值。 预先谢谢您!

0 个答案:

没有答案