Flex: Programmatically firing event listeners - user-interface

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

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.

Get the current active tab from background.js after pages are already loaded

I am developing a Firefox WebExtension. I need to get the current active tab, however, with some additional points. I've successfully managed to get the current active tab from both content script and backgrounde script, however, the events are rised when the page is loaded. The point of my question is that I need to get the active tab even after the pages are loaded. For example, I have 2 tabs in the browser, I managed to get their URL when they are loaded, but when I navigate between them later(when they are already loaded and opened) - I don't get any information. I've managed to solve this question using Alarm(in background script) which will query the current active tab and give me the needed result.
But is it there any better approach to this question? How can I do that without alarms?
You can get the active tab at any time from the background script with tabs.query()
const querying = browser.tabs.query({currentWindow: true, active: true});
querying.then(logTabs, onError);
Update on comment
That is how you get the active tab from background.
The timing is up to you. There are events that you can listen to in order to know when to run the code such as:
tabs.onActivated
tabs.onAttached
tabs.onCreated
tabs.onDetached
tabs.onHighlighted
tabs.onMoved
tabs.onRemoved
tabs.onReplaced
tabs.onUpdated
tabs.onZoomChange
There are also events that can be triggered from the content script and sent to background script with runtime.sendMessage().
It all depends on the situation and when you want to trigger the code.

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!

Addind and removing UI elements in restartless TB 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

How to intercept events from specific windows in OSX

I want to have the following workflow:
User presses hotkey, or status bar menu button
User clicks on a window
Window is now "registered" in my app
App intercepts mouse events from all registered windows
I've read a lot on CGEvents, CGEventTaps and NSEvents. I can intercept global events and post new ones using CGEvents and CGEventTaps but there is not window information like windowNumber in NSEvent, only PSD (and I'm not sure how to use those), so I can't filter out events from non-registered windows. NSEvent, on the other hand, doesn't let me to intercept global events, only local ones through a localMonitor.
How could I achieve the desired functionality?
You can use the Mac OS X Accessibility API to get details about the currently focused window or application.
The UIElementInspector Apple Sample Code gives many examples.
// Given a uiElement and its attribute, return the value of an accessibility object's attribute.
+ (id)valueOfAttribute:(NSString *)attribute ofUIElement:(AXUIElementRef)element;
Use the kAXFocusedApplicationAttribute or kAXFocusedWindowAttribute attributes with valueOfAttribute:ofUIElement: to get the window/app when you "register" it with your app.
When a CGEvent comes in, compare the currently focused window/app to your list of registered windows/apps to determine if the event should be intercepted.

Resources