merlinvn / controlp5

Automatically exported from code.google.com/p/controlp5
0 stars 0 forks source link

ControlP5group example broken in 0.6.12 #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. open ControlP5group example in examples browser
2. hit play

What is the expected output? What do you see instead?
errors about class "Radio" not being found, other errors

What version of the product are you using? On what operating system?
(All platforms), v0.6.12

Please provide any additional information below.

Here is a corrected sketch (adapted from the controlP5radio example:

/**
 * ControlP5 Group
 * by andreas schlegel, 2009
 */
import controlP5.*;

ControlP5 controlP5;

void setup() {
  size(400,400);
  frameRate(30);

  controlP5 = new ControlP5(this);
  ControlGroup l = controlP5.addGroup("myGroup",100,200);
  controlP5.addBang("A-1",0,4,20,20).setGroup(l);
  controlP5.addBang("A-2",30,4,20,20).setGroup(l);
  l.setBackgroundColor(color(255,100));
  l.setBackgroundHeight(150);
  println("the height of controlgroup l: "+l.getBackgroundHeight());

  ControlGroup l2 = controlP5.addGroup("myGroup2",100,40,200);
  l2.activateEvent(true);

  controlP5.addBang("B-1",0,4,20,20).setGroup(l2);
  RadioButton r = controlP5.addRadioButton("radio",100,4);
  addToRadioButton(r,"black",0);
  addToRadioButton(r,"red",1);
  addToRadioButton(r,"green",2);
  addToRadioButton(r,"blue",3);
  addToRadioButton(r,"grey",4);
  r.setColorLabel(0xffff0000);
  r.setGroup(l2);

}

void draw() {
  background(0);
}

void controlEvent(ControlEvent theEvent) {
  if(theEvent.isGroup()) {
    println("got an event from group "+theEvent.group().name()+", isOpen? "+theEvent.group().isOpen());  
  } else if (theEvent.isController()){
    println("got something from a controller "+theEvent.controller().name());
  }
}

void keyPressed() {
  if(key==' ') {
    controlP5.group("myGroup").remove();
  }
}

void addToRadioButton(RadioButton theRadioButton, String theName, int theValue 
) {
  Toggle t = theRadioButton.addItem(theName,theValue);
  t.captionLabel().setColorBackground(color(80));
  t.captionLabel().style().movePadding(2,0,-1,2);
  t.captionLabel().style().moveMargin(-2,0,0,-3);
  t.captionLabel().style().backgroundWidth = 46;
}

Original issue reported on code.google.com by evanras...@gmail.com on 6 Jan 2012 at 6:30

GoogleCodeExporter commented 8 years ago
the Radio class has been removed and replaced by RadioButton, the example has 
not been updated yet, fixed with version 0.7.0

Original comment by soj...@gmail.com on 18 Jan 2012 at 2:17