/** * 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.getCaptionLabel().setColorBackground(color(255,80)); t.getCaptionLabel().style().moveMargin(-7,0,0,-3); t.getCaptionLabel().style().movePadding(7,0,0,3); t.getCaptionLabel().style().backgroundWidth = 45; t.getCaptionLabel().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