Trying to add event listener to compose-window-init

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to add event listener to compose-window-init

cassandra.gelvin
I'm writing an add-on (I'm new to this but have decent JS experience) and having trouble adding an event listener to "compose-window-init". I can get an event listener to work with 'window.addEventListener("load"...' but using 'window.addEventListener("compose-window-init"...' just gives the console message "window.controllers is deprecated. Do not use it for UA detection." and the code doesn't run. How can I run a function when someone hits reply on a message?

Overall, what I'm trying to do is write an add-on that restores the behavior in previous versions of Thunderbird where hitting the keyboard shortcut for Reply didn't ignore the Reply-To header in the message. This seems like it would be fairly straightforward, but I'm having trouble just getting started.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Trying to add event listener to compose-window-init

R Kent James
On 8/22/2017 4:55 PM, [hidden email] wrote:
> I'm writing an add-on (I'm new to this but have decent JS experience) and having trouble adding an event listener to "compose-window-init". I can get an event listener to work with 'window.addEventListener("load"...' but using 'window.addEventListener("compose-window-init"...' just gives the console message "window.controllers is deprecated. Do not use it for UA detection." and the code doesn't run. How can I run a function when someone hits reply on a message?
>
> Overall, what I'm trying to do is write an add-on that restores the behavior in previous versions of Thunderbird where hitting the keyboard shortcut for Reply didn't ignore the Reply-To header in the message. This seems like it would be fairly straightforward, but I'm having trouble just getting started.
>

In Thunderbird 52, I have this code that works just fine (in a content
window):

addEventListener("compose-window-init",
   function () {exquilla.messengerComposeOverlay.onInit();}, true);
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Trying to add event listener to compose-window-init

cassandra.gelvin
On Tuesday, August 22, 2017 at 8:15:08 PM UTC-7, R Kent James wrote:

> On 8/22/2017 4:55 PM, [hidden email] wrote:
> > I'm writing an add-on (I'm new to this but have decent JS experience) and having trouble adding an event listener to "compose-window-init". I can get an event listener to work with 'window.addEventListener("load"...' but using 'window.addEventListener("compose-window-init"...' just gives the console message "window.controllers is deprecated. Do not use it for UA detection." and the code doesn't run. How can I run a function when someone hits reply on a message?
> >
> > Overall, what I'm trying to do is write an add-on that restores the behavior in previous versions of Thunderbird where hitting the keyboard shortcut for Reply didn't ignore the Reply-To header in the message. This seems like it would be fairly straightforward, but I'm having trouble just getting started.
> >
>
> In Thunderbird 52, I have this code that works just fine (in a content
> window):
>
> addEventListener("compose-window-init",
>    function () {exquilla.messengerComposeOverlay.onInit();}, true);

Thanks so much for responding. Can you tell me what you mean by "a content window"? I'm starting from the tutorial code and modifying it from there, so my manifest looks like this:

content     stopignoringreplyto    content/
overlay chrome://messenger/content/messenger.xul chrome://stopignoringreplyto/content/stopignoringreplyto.xul

stopignoringreplyto.xul looks like this:

<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <script type="application/javascript" src="chrome://stopignoringreplyto/content/overlay.js"/><!-- A reference to your JavaScript file -->
 <statusbar id="status-bar">
  <statusbarpanel id="my-panel" label="Date"/>
 </statusbar>
</overlay>

and overlay.js looks like this:

window.addEventListener("compose-window-init", function() {
        startup();
}, true);

function startup() {
        console.log("test");
}

Am I putting something in the wrong place? I'm having trouble telling whether the console message is actually related to my add-on because it's saying that it's from "blank", but I'm not getting the word "test" written to the console when I start to compose a new message, reply or not, and as I understand it that's when the event should be firing, right? The word "test" is being written to the console when the program starts if I replace "compose-window-init" with "load". Thanks again for any help. Like I said, I'm new at Thunderbird add-ons.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Trying to add event listener to compose-window-init

cassandra.gelvin
On Wednesday, August 23, 2017 at 11:52:21 AM UTC-7, Cassandra Gelvin wrote:

> On Tuesday, August 22, 2017 at 8:15:08 PM UTC-7, R Kent James wrote:
> > On 8/22/2017 4:55 PM, [hidden email] wrote:
> > > I'm writing an add-on (I'm new to this but have decent JS experience) and having trouble adding an event listener to "compose-window-init". I can get an event listener to work with 'window.addEventListener("load"...' but using 'window.addEventListener("compose-window-init"...' just gives the console message "window.controllers is deprecated. Do not use it for UA detection." and the code doesn't run. How can I run a function when someone hits reply on a message?
> > >
> > > Overall, what I'm trying to do is write an add-on that restores the behavior in previous versions of Thunderbird where hitting the keyboard shortcut for Reply didn't ignore the Reply-To header in the message. This seems like it would be fairly straightforward, but I'm having trouble just getting started.
> > >
> >
> > In Thunderbird 52, I have this code that works just fine (in a content
> > window):
> >
> > addEventListener("compose-window-init",
> >    function () {exquilla.messengerComposeOverlay.onInit();}, true);
>
> Thanks so much for responding. Can you tell me what you mean by "a content window"? I'm starting from the tutorial code and modifying it from there, so my manifest looks like this:
>
> content     stopignoringreplyto    content/
> overlay chrome://messenger/content/messenger.xul chrome://stopignoringreplyto/content/stopignoringreplyto.xul
>
> stopignoringreplyto.xul looks like this:
>
> <?xml version="1.0"?>
> <overlay id="sample"
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
>  <script type="application/javascript" src="chrome://stopignoringreplyto/content/overlay.js"/><!-- A reference to your JavaScript file -->
>  <statusbar id="status-bar">
>   <statusbarpanel id="my-panel" label="Date"/>
>  </statusbar>
> </overlay>
>
> and overlay.js looks like this:
>
> window.addEventListener("compose-window-init", function() {
> startup();
> }, true);
>
> function startup() {
> console.log("test");
> }
>
> Am I putting something in the wrong place? I'm having trouble telling whether the console message is actually related to my add-on because it's saying that it's from "blank", but I'm not getting the word "test" written to the console when I start to compose a new message, reply or not, and as I understand it that's when the event should be firing, right? The word "test" is being written to the console when the program starts if I replace "compose-window-init" with "load". Thanks again for any help. Like I said, I'm new at Thunderbird add-ons.

Ah, it was the manifest. I needed to change "chrome://messenger/content/messenger.xul" to "chrome://messenger/content/messengercompose/messengercompose.xul". It's been frustrating not having an up-to-date version of Dom Inspector. I just unzipped it, modified the install.rdf, and rezipped it and it seems to be working, so that should help me out. Thanks again.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Trying to add event listener to compose-window-init

Jörg Knobloch
On 23/08/2017 23:45, Cassandra Gelvin wrote:
> It's been frustrating not having an up-to-date version of Dom Inspector. I just unzipped it, modified the install.rdf, and rezipped it and it seems to be working, so that should help me out.

Are you working on trunk or something older. For trunk you need:
www.jorgk.com/misc/inspector-2.0.17.1.xpi

Jörg.

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird