initial checkin
[org.ibex.widgets.git] / src / ibex / lib / repeatable.t
1 <!-- Copyleft 2004 - see COPYING for details [LGPL] -->
2
3 <ibex>
4     <meta:doc>
5         Author: Charles Goodwin
6
7         See ibex.theme.repeatable for details
8     </meta:doc>
9
10     <ui:box>
11
12         thisbox.counter = 0;        // consecutive repetition counter
13         thisbox.interval = 100;     // repetition interval (ms)
14         thisbox.initialinterval;    // the initial interval of a repeating action
15         thisbox.repeat;             // repeating state 
16
17         interval ++= function() {
18             // return interval for counter > 0 or initialinterval otherwise
19             return counter ? cascade : initialinterval ? initialinterval : cascade;
20         }
21
22         repeat ++= function(v) {
23             if (v) {
24                 // only start if previously false
25                 if (!repeat) {
26                     cascade = v;
27  
28                     ibex.thread = function() {
29                         while (repeat) {
30                             action = true;
31                             counter ++;
32                             ibex.thread.sleep(interval);
33                         }
34                     }
35                 }
36             }
37             else counter = 0;
38         }
39
40     </ui:box>
41 </ibex>