Timer
axTimer
Description
axTimer allows a timer to be added to the screen. The timer is not visible at run time. When the timer interval has passed, the timer ticks and executes the script specified.
The timer can be set to tick repeatedly or just once, or by setting the interval to 0, it can be set to not tick at all.
A timer would normally be added as a new element to a screen. When creating the new element you will need to manually uncheck the default visualization.
A timer will be invisible unless the screen is being edited.
There can be multiple timers on a screen.
Usability
Context |
Supported |
|---|---|
|
Input screen fields |
Yes |
|
Output screen fields |
Yes |
|
Input subfile fields |
No |
|
Output subfile fields |
No |
|
New screen elements |
Yes |
Properties
Name |
Description and Comments |
JavaScript |
Shipped default |
|---|---|---|---|
|
tickInterval |
This is the time between ticks, in milliseconds |
Yes |
0 |
|
onTick |
This is the script that will be executed when the timer ticks |
Yes |
alert('timer tick occurred'); |
|
keepTicking |
This indicates whether the timer will tick once and stop (false) or tick repeatedly (true) |
Yes |
true |
Warnings
When creating a new element, you will need to check the timer extension and uncheck the default visualization extension.
Examples
Example 1:
Add a timer that ticks once, after 10 seconds, and issues an alert
Edit a screen and add a new element to it, and make it a Timer
Set its properties to:
tickInterval: 10000
onTick:
alert('10 seconds has elapsed');
keepTicking : false
Save the screen. After 10 seconds an alert will appear:
"10 seconds has elapsed"
If you click ok on the alert, the timer will not tick again, because property keepTicking is false.
Example 2:
Add a timer that checks every 10 seconds whether the user has entered a value, and stops checking when a value has been entered.
Find and edit a screen with an input field on it.
Name the input field "myField".
Add a new element to the screen and make it a timer.
Set its properties to:
tickInterval: 10000
onTick:
alert('timer 10 seconds tick occurred');
var F = FIELDS("myField");
if ( F.getValue() != "")
{
alert("setting my tick interval to 0");
FIELD.setProperty("tickInterval", 0);
FIELD.refresh();
}
keepTicking : true
Save the screen and ensure the field named myField is blanked out.
Every 10 seconds an alert will appear: "timer 10 seconds tick occurred".
Type in a value into the field named "myField".
The next alert will be:
"timer 10 seconds tick occurred"
followed by:
"setting my tick interval to 0"
Then there will be no more ticks, because the timer's interval has been set to zero.
Example 3:
Add a timer that changes the style of an input field, after 2 seconds.
Find and edit a screen with an input field on it.
Change the field to use the Default Visualization and the Timer extension.
Set the input field's properties as follows:
tickInterval: 2000
onTick:
var oStyle = null;
oStyle = {"color":"red", "background":"blue"};
FIELD.setProperty("axdv.style" , oStyle );
FIELD.refresh();
keepTicking: false
Note that the style that is changed is the style of the default visualization, and this is distinguished from the Basic style by using "axdv.style"
