SliderEvent.clickTarget does not change - apache-flex

In my web based flex app I have a HSlider to which 'change' event listener is binded. Inside the event listener function I have the following.
trace('slider click target: '+e.clickTarget);
I am changing the slider value from a timer (say every second). At this time, in the console I see that traget is being printed as null every second.
Now, if I change the value by dragging the thumb, it prints target as thumb. And then onwards it keeps printing the target as thumb every second instead of printing null. The same thing happens if change the slider value by clicking track (it keeps printing track).
Basically, I have the event listener to find out if the value of the slider is changing due to the timer, click on thumb or click on track. Kindly let me know if this issue can be fixed or is there any other approach I can follow. Thanks!!

This is strange, because the documentation says that the change event is dispatched when the slider changes value due to mouse or keyboard interaction - the event is not triggered when you change it programmatically, and the listener shouldn't even be called.
Are you calling the event listener manually? Post some more code - where you update the slider value and the full event listener.

Related

Timer until Event Occurs

Is there a way to track the time from when the "Window Loaded" event happens until a button is clicked on the page?
I tried several different things, like setting up a timer that would only fire if "Click Text" is "Download" but that doesn't stop the timer trigger from firing every second. I could never stop the timer on an event or a button click.
Brian
I found this answer from Simo about how to do this:
https://productforums.google.com/d/msg/tag-manager/xJ0RGC2wecY/rxmrJRklAgAJ
When you create a Universal Analytics tag, you need to add in all the required fields. Now you don't have any fields populated in your Timing hit so GA can't build any hit out of it.
You need to fill at least Category, Variable and Value fields: https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings
But judging from the bit you wrote at the end of your latest response, I think you've kind of misunderstood how the timer trigger works.
The timer trigger STARTS a timer upon the page load (GTM's default timer) or any user interaction (my custom timer). You still need to specify a "stop" to the timer to calculate how long something took. Neither GTM's default timer or my timer trigger can help you in identifying how long something took. They can simply be used to measure IF something took X seconds, where X seconds is the interlap between "interval" and "limit".
If you want to know the number of milliseconds from when the page was first loaded in the browser to any interaction such as a click of a button, all you need is a Custom JS variable:
function() {
return window.performance && window.performance.timing ? (new Date().getTime())-window.performance.timing.domInteractive : undefined;
}
This variable would return the time delta in milliseconds between when the variable was invoked and when the current page first became available to the user. So if you want to create a Timing tag out of this, make the Timing tag fire on the click of the button, and then in the timing Value field add a reference to this variable. Thus you'll have a Timing tag that sends the duration it took for user to land on the page and then click the button.
Simo

filter mouse move event and send again

My program is working on Qt, and I have a problem and there is free answer for it in website.
Our products need to update image while user move mouse, but the updating image is very time-consuming.If user move the mouse quickly, the system will generate a lot of mouse movement events, eventually leading to clogging of the background process.Therefore, we need to filter out part of the event.
I filter mouse move event by insert event filter in QApplication:
qApp->insertEventFilter(this)
Once I catch mouse event, I will store QMouseEvent and pointer of QObject, and active QTimer. other mouseMouseEvent will can overwrite them before timeout. After timeout, the last event will be post.
I can't use:
QApplication::sendEvent(XX) or postEvent(xx)
because it will be catched by my event filter again.
How can I make it work?
Don't filter the events. Instead of that, change your background worker which is responsible for producing the data to make sure that you do not spend time on stuff you won't need.

QTableView: Best way to change activation-trigger to double-click

In my application, I have one tableview of items, and a side-panel "preview":ing the latest selected item.
I want clicking on an item to change the selection, and double-clicking to cause a "run"-action to be performed. More specifically, I want the "run"-action (including key-navigation and pressing enter) to be bound to the "activation" of the item in the table-row.
My problem is; single-clicks does not only change the selection, but fires the "activated" signal on the item. I would like to tweak it such that:
Navigation Keys, Single Mouse Click: Selection-change, update preview-panel
Enter Key, Double Mouse Click: Activate/run/open action triggered.
Is there a nice clean way to do it, or are overriding the onclick/doubleclick events my best option? Or is there some other tabular list-widget better suiting my needs?
I would connect the slot for the preview action to the currentChanged() signal of the table view's selectionModel(). This covers single clicks and key navigation.
Then there's two options for the double clicks and Enter key presses:
Subclass your tableview, override doubleClickEvent() and keyPressEvent() and fire your custom signal in there, with maybe the model index or something else as an argument. Then just connect your run method to your own signal as you have full control over when it is fired.
If you don't want to subclass, you can use the installEventFilter() mechanism.
Either I'm getting your approach wrong or I'm too tired, but if you want to trigger a run event you should avoid the activated signal completely. Set the signal slot mechanism so that your double click and Enter key press event trigger your run() function, and then the single click/nav buttons should trigger the 'activated' slot which will return your index in the tableview.
I'm pretty certain Qt wants you to be explicit about which signal points to which slot or it'll ignore it or point to a default.

Changing a dialog button's text at runtime in Qt

I have a button named 'Start', and when it's clicked, a lengthy operation starts and I want it to change to a button named 'Stop'. The behavior when you click it obviously changes as well. What is the best way to implement this - by changing the button's text and reconnecting the 'clicked()' signal to a different slot, or by having two buttons and then hiding 'Start' and showing 'Stop'.
Both of your options work. A simple third alternative is to change the button text (changing the icon would be a good idea too), and saving the "state" (playing/not playing) somewhere. In your connected slot, just do the Right Thing depending on current state. (That way you don't have to reconnect anything).
Another option is to use the push button with setCheckable(true) set. This way the button acts more like a toggle-button (stays depressed when first clicked, raises back with second click), and combining that with your dynamic text/icon change.
If you use this, you should use the toggled(bool) signal rather than the clicked() one. The slot argument tells you whether the button is "active" or not. (This can also be queried with isChecked().)

What the best way to coordinate loading initial values in syncronized Combo-Boxes & List Box

Environment: Flex/As3/Cairgorm/composite component.
I have two comboboxes and two datagrids such that the selection of combobox 1, inserts data into combobox two and the fist datagrid. The selection of combobox 2 inserts data into datagrid 2.
I have setup the change event so that the user selection on each of the combo boxes do the right thing. The problem is that on the initial load of the comboboxes, the change event does not fire and subsequent synchronization data loading does not happen.
Is there an event for getting the itemselected (1st item) after the combobox is initialized?
I found my own answer. Using the updateComplete event on each of the comboboxes did the trick.
[EDIT]
It turns out that updateComplete did not work as expected. What I really needed is the dataChange event. However, it appears that this event does not fire for comboboxes even though it is listed as a valid FlexEvent for this component.
I tried a number of other events (valueCommit, creationComplete, initialize) but all of these fire multiple times, overlap with change, and are not useful for this usecase.
In the end, I created a gludge of a chain of calls for the initialize path and change path.
If anyone else has a better way, I'd be very interested.

Resources