1 <!-- Copyleft 2004 - see COPYING for details [LGPL] -->
5 Author: Charles Goodwin
8 - be more restrictive of puts to value
9 - value needs to be trappable
16 thisbox.interval; // interval by which up/down in/de-crement the result
17 thisbox.maxvalue; // maximum value of the result
18 thisbox.minvalue; // minimum value of the result
19 thisbox.precision; // number of decimal places of result
21 var is_int; // parse integeters or floats
23 // theme box variables
25 thisbox.th_less; // the button to decrement
26 thisbox.th_more; // the button to increment
27 thisbox.th_output; // the th_output for the result
29 // private function to get the value from a string
30 var parse = function(v) { return is_int ? ibex.math.parseInt(v) : ibex.math.parseFloat(v); }
32 // write trap to establish is_int based on interval
33 interval ++= function(v) { is_int = !(v % 1); }
35 KeyPressed ++= function(v) {
36 if (v == "down" or v == "DOWN") th_less.action = true;
37 else if (v == "up" or v == "UP") th_more.action = true;
40 value ++= function() { return ibex.string.parse(th_output.text); }
42 value ++= function(v) { th_output.text = "" + v; }
46 th_less ++= function(v) {
47 v.action ++= function(v) {
48 th_output.text = "" + ibex.math.max(parse(th_output.text) - interval, minvalue);
52 th_more ++= function(v) {
53 v.action ++= function(v) {
54 th_output.text = "" + ibex.math.min(parse(th_output.text) + interval, maxvalue);