回答編集履歴
1
permalink
test
CHANGED
@@ -1,107 +1,54 @@
|
|
1
1
|
`Toggle`にキャストすれば`.setValue(false)`や`.setState(false)`とできますが、めんどくさいので`.changeValue(0)`や`.setValue(0)`でいいんじゃないですかね?
|
2
|
-
|
3
2
|
[Toggle#setValue(boolean theValue) - (Javadocs: controlP5)](http://www.sojamo.de/libraries/controlP5/reference/controlP5/Toggle.html#setValue-boolean-)
|
4
|
-
|
5
3
|
[Toggle#setState(boolean theFlag) - (Javadocs: controlP5)](http://www.sojamo.de/libraries/controlP5/reference/controlP5/Toggle.html#setState-boolean-)
|
6
4
|
|
7
|
-
|
8
|
-
|
9
5
|
ゼロが`false`で、それ以外は`true`のようです。
|
10
|
-
|
11
|
-
[controlp5/Toggle.java at master · sojamo/controlp5](https://github.com/sojamo/controlp5/blob/
|
6
|
+
[controlp5/Toggle.java at master · sojamo/controlp5](https://github.com/sojamo/controlp5/blob/1f7cb649865eb8657495b5cfeddd0dbe85d70cac/src/controlP5/Toggle.java#L94)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
7
|
|
16
8
|
|
17
9
|
```Processing
|
18
|
-
|
19
10
|
import controlP5.*;
|
20
|
-
|
21
11
|
import java.util.*;
|
22
|
-
|
23
|
-
|
24
12
|
|
25
13
|
ControlP5 cp5;
|
26
14
|
|
27
|
-
|
28
|
-
|
29
15
|
void setup() {
|
30
|
-
|
31
16
|
size(400, 400);
|
32
|
-
|
33
17
|
cp5 = new ControlP5(this);
|
34
18
|
|
35
|
-
|
36
|
-
|
37
19
|
cp5.addToggle("sampleToggle")
|
38
|
-
|
39
20
|
.setPosition(10, 10)
|
40
|
-
|
41
21
|
.setValue(true);
|
42
22
|
|
43
|
-
|
44
|
-
|
45
23
|
cp5.addKnob("sampleKnob")
|
46
|
-
|
47
24
|
.setPosition(10, 100)
|
48
|
-
|
49
25
|
.setRange(0, 100)
|
50
|
-
|
51
26
|
.setValue(10);
|
52
27
|
|
53
|
-
|
54
|
-
|
55
28
|
cp5.addScrollableList("list")
|
56
|
-
|
57
29
|
.setPosition(100, 10)
|
58
|
-
|
59
30
|
.setBarHeight(20)
|
60
|
-
|
61
31
|
.setItemHeight(20)
|
62
|
-
|
63
32
|
.addItems(Arrays.asList("toggle", "knob"));
|
64
|
-
|
65
33
|
}
|
66
34
|
|
67
|
-
|
68
|
-
|
69
35
|
void list(int n) {
|
70
|
-
|
71
36
|
if (n == 0) {
|
72
|
-
|
73
37
|
cp5.getController("sampleToggle")
|
74
|
-
|
75
38
|
.changeValue(0); // setValue(0)も同じ
|
76
39
|
|
77
|
-
|
78
|
-
|
79
40
|
//Toggle toggle = (Toggle)cp5.getController("sampleToggle");
|
80
|
-
|
81
41
|
//toggle.setValue(false); // setState(false)も同じ
|
82
|
-
|
83
42
|
// ↑↓同じ意味
|
84
|
-
|
85
43
|
//((Toggle)cp5.getController("sampleToggle")).setValue(false);
|
86
|
-
|
87
44
|
|
88
|
-
|
89
45
|
} else if (n == 1) {
|
90
|
-
|
91
46
|
cp5.getController("sampleKnob")
|
92
|
-
|
93
47
|
.changeValue(50);
|
94
|
-
|
95
48
|
}
|
96
|
-
|
97
49
|
}
|
98
50
|
|
99
|
-
|
100
|
-
|
101
51
|
void draw() {
|
102
|
-
|
103
52
|
background(128);
|
104
|
-
|
105
53
|
}
|
106
|
-
|
107
54
|
```
|