1

I am trying to open a window from another window in javascript (in a Thunderbird addon). I am able to achieve the desired result, but the problem is I am not able to modify the contents of the window dynamically either before or after. Also window objects appear to not trigger any event at all...

Here is my .js function that gets called first:

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

Here is my .xul file which gets opened:

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

I really don't understand how am I supposed to change the .xul programmatically. Precisely, I need to change the <textbox> value. Thank you in advance !

Damian
  • 75
  • 1
  • 9

0 Answers0