DateRange component events
| Author |
Message |
|
quper
Lieutenant
Joined: Thu Feb 16, 2012 7:05 am Posts: 63
|
 DateRange component events
Hi! I need to fire event when I move DateRange component slider. I was trying to do that with MouseReleased event, but it does not work on slider himself. It works on every other place of DateRange component around that slider, but not on slider. How is it possible to fire MouseReleased event on DateRange slider?
Thanks.
|
| Fri May 04, 2012 6:10 am |
|
 |
|
Travis.Cox
Moderator
Joined: Sun Apr 02, 2006 2:46 pm Posts: 1975 Location: Sacramento, CA
|
 Re: DateRange component events
You don't use the mouseReleased event but rather the propertyChange event. It fires anytime a property on that component changes. So for the date range you can do this: Code: if event.propertyName in ["startDate", "endDate"]: # do your code here .....
_________________ Travis Cox
Inductive Automation
Technical Support Rep.
|
| Fri May 04, 2012 8:26 am |
|
 |
|
quper
Lieutenant
Joined: Thu Feb 16, 2012 7:05 am Posts: 63
|
 Re: DateRange component events
Thank you. Now I have such problem, that if I change DateRange component endTime and startTime, sometimes my code behind DateRange component event handler runs two times. I change endTime and startTime like this: Code: event.source.parent.getComponent('Date Range').endDate = newEndDate event.source.parent.getComponent('Date Range').startDate = newStartDate
And it seems that event fires on every date change, first time on endDate change and second time on startDate change. Is it possible to change endDate and startDate at once, at the same time?
|
| Sun May 06, 2012 10:08 pm |
|
 |
|
Travis.Cox
Moderator
Joined: Sun Apr 02, 2006 2:46 pm Posts: 1975 Location: Sacramento, CA
|
 Re: DateRange component events
No, you will get two property changes. However, you can run your script in an invokeLater function which will happen after both values update.
_________________ Travis Cox
Inductive Automation
Technical Support Rep.
|
| Mon May 07, 2012 7:33 am |
|
 |
|
quper
Lieutenant
Joined: Thu Feb 16, 2012 7:05 am Posts: 63
|
 Re: DateRange component events
Thing is that I am changing DateRange times from several places, not only by dragging slider. But I also want to drag it and fire my event behind that also. I have a time change panel, where I control endTime and startTiime of DateRange component and also dragging a slider possibility. This DateRange component controls my ClassicChart datasets by refreshing queries. And now those queries run double. Are you having plans to add Event Handler to DateRange slider itself as well?
|
| Tue May 08, 2012 9:08 pm |
|
 |
|
Travis.Cox
Moderator
Joined: Sun Apr 02, 2006 2:46 pm Posts: 1975 Location: Sacramento, CA
|
 Re: DateRange component events
I understand. We don't have any plans right now to fix that. You can add a button to the window that they can click on to refresh the data.
_________________ Travis Cox
Inductive Automation
Technical Support Rep.
|
| Wed May 09, 2012 7:17 am |
|
 |
|
quper
Lieutenant
Joined: Thu Feb 16, 2012 7:05 am Posts: 63
|
 Re: DateRange component events
Ok, I made multiple queries run behind button using system.db.runQuery("query") for every dataset in Classic Chart and using invokeAsynchronous, to run them all at once in separate threads. Now I am not able to indicate datasets loading using Chart propertiesLoading, because query excecutes in system function and Chart datasets filling runs so fast, that I don't even see it. I putted indicator visibility to 1 behind RunQueries button, but I don't know how to turn visibility off, because I don't know how to get when Chart datasets finish loading. Could you help me somehow with that?
|
| Mon May 14, 2012 6:19 am |
|
 |
|
Travis.Cox
Moderator
Joined: Sun Apr 02, 2006 2:46 pm Posts: 1975 Location: Sacramento, CA
|
 Re: DateRange component events
Sure, you can put a progress bar or image on the screen that shows it is loading. In your script you can show/hide the progress bar like this: Code: def doAsynch(event=event): import fpmi
def doLater(event=event): event.source.parent.getComponent("Progress Bar").visible = 1 fpmi.util.invokeLater(doLater)
....... # your code
def doLater(event=event): event.source.parent.getComponent("Progress Bar").visible = 0 fpmi.util.invokeLater(doLater)
fpmi.util.invokeAsynchronous(doAsynch) You have to use a invokeLater to change any properties on the screen.
_________________ Travis Cox
Inductive Automation
Technical Support Rep.
|
| Mon May 14, 2012 7:34 am |
|
 |
|