summaryrefslogtreecommitdiff
path: root/src/examples/spinner_example.js
blob: ab582fda7b5fdcb6c6e33e593e9c05c9b10a4476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

elm = require('elm');

win = new elm.Elm.WinStandard(null);
win.setTitle("Spinner Example");
win.setAutohide(true);

bx = new elm.Elm.Box(win);
bx.setSizeHintWeight(1.0, 1.0);
win.resizeObjectAdd(bx);
bx.setVisible(true);

sp = new elm.Elm.Spinner(win);
sp.setSizeHintWeight(1.0, 1.0);
sp.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp);
sp.setVisible(true);

sp2 = new elm.Elm.Spinner(win);
sp2.setLabelFormat("Percentage %%%1.2f something");
sp2.setSizeHintWeight(1.0, 1.0);
sp2.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp2);
sp2.setVisible(true);

sp3 = new elm.Elm.Spinner(win);
sp3.setLabelFormat("%1.1f units");
sp3.setStep(1.5);
sp3.setWrap(true);
sp3.setMinMax(-50.0, 250.0);
sp3.setSizeHintWeight(1.0, 1.0);
sp3.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp3);
sp3.setVisible(true);

sp4 = new elm.Elm.Spinner(win);
sp4.setStyle("vertical");
sp4.setInterval(0.2);
sp4.setSizeHintWeight(1.0, 1.0);
sp4.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp4);
sp4.setVisible(true);

sp5 = new elm.Elm.Spinner(win);
sp5.setEditable(false);
sp5.setSizeHintWeight(1.0, 1.0);
sp5.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp5);
sp5.setVisible(true);

sp6 = new elm.Elm.Spinner(win);
sp6.setEditable(false);
sp6.setMinMax(1, 12);
sp6.specialValueAdd(1, "January");
sp6.specialValueAdd(2, "February");
sp6.specialValueAdd(3, "March");
sp6.specialValueAdd(4, "April");
sp6.specialValueAdd(5, "May");
sp6.specialValueAdd(6, "June");
sp6.specialValueAdd(7, "July");
sp6.specialValueAdd(8, "August");
sp6.specialValueAdd(9, "September");
sp6.specialValueAdd(10, "October");
sp6.specialValueAdd(11, "November");
sp6.specialValueAdd(12, "December");
sp6.setSizeHintWeight(1.0, 1.0);
sp6.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp6);
sp6.setVisible(true);

sp7 = new elm.Elm.Spinner(win);
sp7.setSizeHintWeight(1.0, 1.0);
sp7.setSizeHintAlign(-1.0, 0.5);
bx.packEnd(sp7);
sp7.setVisible(true);
sp7.setEditable(true);

sp7.on('changed',
  function(obj)
  {
      console.log("Value changed to " + obj.getValue());
  });

sp7.on('delay_changed',
  function(obj)
  {
      console.log("Value delay changed to " + obj.getValue());
  });

win.setVisible(true);