did you read this:
this seems to be important:
void radioButton(int a) {
println("a radio Button event: "+a);
}
full code:
/**
* ControlP5 RadioButton
*
*
* find a list of public methods available for the RadioButton Controller
* at the bottom of this sketch.
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/
import controlP5.*;
ControlP5 cp5;
int myColorBackground = color(0, 0, 0);
RadioButton r;
void setup() {
size(700, 400);
cp5 = new ControlP5(this);
r = cp5.addRadioButton("radioButton")
.setPosition(20, 160)
.setSize(40, 20)
.setColorForeground(color(120))
.setColorActive(color(255))
.setColorLabel(color(255))
.setItemsPerRow(5)
.setSpacingColumn(50)
.addItem("50", 1)
.addItem("100", 2)
.addItem("150", 3)
.addItem("200", 4)
.addItem("250", 5)
;
//for (Toggle t : r.getItems()) {
// t.captionLabel().setColorBackground(color(255, 80));
// t.captionLabel().style().moveMargin(-7, 0, 0, -3);
// t.captionLabel().style().movePadding(7, 0, 0, 3);
// t.captionLabel().style().backgroundWidth = 45;
// t.captionLabel().style().backgroundHeight = 13;
//}
}
void draw() {
background(myColorBackground);
}
void keyPressed() {
switch(key) {
case('0'):
r.deactivateAll();
break;
case('1'):
r.activate(0);
break;
case('2'):
r.activate(1);
break;
case('3'):
r.activate(2);
break;
case('4'):
r.activate(3);
break;
case('5'):
r.activate(4);
break;
}
}
void controlEvent(ControlEvent theEvent) {
if (theEvent.isFrom(r)) {
print("got an event from "+theEvent.getName()+"\t");
for (int i=0; i<theEvent.getGroup().getArrayValue().length; i++) {
print(int(theEvent.getGroup().getArrayValue()[i]));
}
println("\t "+theEvent.getValue());
myColorBackground = color(int(theEvent.group().getValue()*50), 0, 0);
}
}
void radioButton(int a) {
println("a radio Button event: "+a);
}
//