Addind and removing UI elements in restartless TB addon - thunderbird-addon

I develop a restartless addon for Thunderbird. I need to add some UI elements in compose window when the addon is activated.
What I did so far is:
at startup, add an observer on windows via nsIWindowWatcher
at shutdown, remove window observer, and set a variable X to true
when this observer observes domwindowopened event, add a eventlistener to the opened window for "compose-window-init" event (when it observes domwindowclosed, it removes the eventlistener)
when this compose-window-init event is fired, check the document.location of the window, if it corresponds to a message composer:
add the UI elements,
or remove UI elements and remove eventListener, if X is set to true
This works well (UI is added to compose message when addon is activated, and removed when deactivated) except the following : when addon is deactivated then activated again, the first compose message is not provided with the UI elements. The UI is added to the other one, but not to the first.
Any idea on why and how to solve this ?
Thx

I found what was wrong.
See my post at:
http://forums.mozillazine.org/viewtopic.php?f=19&t=2949755&p=14254205#p14254205
Regards

Related

Outlook VSTO - ActiveInspector returns the incorrect contact window's information

Globals.ThisAddIn.Application.Explorers.NewExplorer += new ExplorersEvents_NewExplorerEventHandler(DoNewExplorer);
I am trying to get the information from an email that I previously opened (by double-clicking) in outlook.
The code works fine until I open multiple emails. What I am finding is that when I click on an email, the inspector activates, but I am getting the information from the last active window, not the current one that I clicked on.
In the Activate event handler you can always call the ActiveInspector method of the Outlook Application class.
Note, the Inspectors collection contains all opened inspector windows, so you could get all of them or find the required one.
Firstly, your code tracks the Explorers.NewExplorer event, not Inspectors.NewInspector.
Secondly, for the Inspectors.NewInspector event, make sure you are using the Inspector object passed to your event handler rather than Application.ActiveInspector: by the time Inspectors.NewInspector event fires, the inspector might not yet be visible/active.

Google Tag Manager isn't tracking mobile click to calls

I am trying to track clicks on the phone number on the website. After I set up the trigger using following settings:
Trigger Type: all elements;
Page URL: contains "tel:" ;
Click Text: contains "13";
With these settings, the trigger is firing correctly on the desktop but isn't working on mobile.
I tried to use only "Page URL"/"Text Only"/"Form Text"/"Form contains" as conditions for the trigger to fire, but all attempts are unsuccessful. I also tried to use "Just Links" as a trigger type but it's not helping.
I also tested the URL in different mobile browsers (chrome/safari) and emulator. With an emulator, the tag is firing correctly but it's not working on the
Please have a look at the preview to see the page and tracking I am talking about:
https://www.googletagmanager.com/start_preview/gtm?uiv2&id=GTM-T92J432&gtm_auth=MmNY2ZtOefQOp1Kce4yUFQ&gtm_preview=env-5&gtm_debug=x&url=https://lp.acfc.com.au/good-credit
I appreciate your advice on what is the problem and how it can be fixed.
Thanks!
Kirill
Actually, better way of doing this to set generic trigger in GTM, then you will be able to track any phones on your website:
1) Enable built-in variable Click Element (if you already have it, you can skip this step)
2) Create trigger, which will fire for all links which have tel:***** (it can be any phone).
CSS selector on the screenshot is a[href*="tel:"]
3) Create a tag, which will send data to GA
4) Check your events in GA.
Keep in mind that it might take a couple of hours to appear in Behaviour-> Events tab. Or you can check it immediately in Real Time -> Events tab
RESOLVED:
I just found out that in order to identify an event it is safer to look at how the data layer is changing after the action rather than on the "Variable" tab.
By doing so, you can see what data is actually going to google analytics, and it is more stable to use it as an ID for a trigger to fire.
In my case, I've had only elementURL that was pushed back to the datalayer. I used the parameter elementID equals "tel:xxxxxx" to make the tracker work. Hope it will help (just put your number instead of x).
Cheers!

Nativescript - resumeEvent handling

In my app when the app is resumed from a sleep, I'd like to
reload the page - or ideally, just update specific UI elements.
How can this be done?
Preferably in a platform independent way.
You want to hook into the onResume method in the application module which exposes the event when an app resumes from the background.
https://docs.nativescript.org/api-reference/modules/application.html#onresume
So in your app.js (the entry point of your application), import the module and add the onResume event handler and it can run everytime the app resumes. Now reloading a page will require a little more work. You'd have to use the frame module and find out the current page and do your work, but I'm guessing it can be done with a little effort using the approach mentioned.
UPDATE: based off your comment, you need the reloadPage() method from the ui/frame module. https://docs.nativescript.org/api-reference/modules/_ui_frame_.html#reloadpage
The correct method is reloadPage() in the Frame module (as contributed by #Brad) but the problem is that it's NOT an exposed api.
No problem - just copy/paste it and it works.
The problem is that it basically does a navigateTo() to the currentPage and that effects the navigation history. You have 2 choices - setting clearHistory to true and you lose all history (don't want that) or set clearHistory to false which creates a a duplicate of the current-page (don't want that either). There's also a backstackVisible option but that doesn't help in this scenario.
#Brad tells me that there's api that allows access to the navigation stack - haven't looked into it.
For my app - the user will be at the root page most of the time, so I decided to reload the page only if on the root page and then set clearHistory to true and that works for me.

Chrome App Lifecycle

I'm reading through Chrome App Lifecycle. The model looks very simple. There's an onLaunch and onSuspend.
A few questions:
1) Is it possible to detect a transition from foreground to background?
2) Does Chrome persist any state automatically before moving to the background?
3) Does Chrome snap a capture of the app's window before moving to the background?
4) Does the same apply to Chrome Packaged Apps?
1) Yo'll only receive onSuspend event right before event page become inactive. If you want to know when the user close app's window you need to listen for page unload event in the app an inform event page about the fact (using chrome.runtime API).
2) If you set "id" parameter for chrome.app.window.create options object, Chrome will persist window state: width, height, top and left position and screen number and restore it during next app bootstrap. You can override this behavior setting your own values in chrome.app.window.create method.
3) As far as I know - no.
4) No. It is different kind of apps.

Flex: Programmatically firing event listeners

I would like to programmatically fire an event on a spark checkbox.
I have a tab bar which has tabs enabled according to various checkboxes. I am loading data into these tabs. Sometimes tabs 1 and 2 will be enabled. Other times tabs 2 and 3. Other times tab 4 by itself (and all the other combinations).
I have tried to enable the VBox (in action script) which is in my view stack but it seems to freeze the application. The VBox enables correctly upon user input on the check box. If I set the checkbox to be selected it does not fire the event and so does not enable the tab. Is it possible to manually fire an event in Flex. I have tried to see if I can take the checkbox and get the event and fire it. Unfortunately I can only see addEventListener, hasEventLister and removeEventListener. There is no way of getting the events that are already on the checkbox
To dispatch and event from a component:
component.dispatchEvent(event)
Example:
var evt:MouseEvent=new MouseEvent(MouseEvent.CLICK)
this.checkBox.dispatchEvent(evt)
it doesn't put the selecte mark but you could set it programmaticaly with
this.checkBox.selected=true

Resources