# controlP5 RadioButton question

**URL:** https://discourse.processing.org/t/controlp5-radiobutton-question/11211
**Category:** Libraries
**Created:** [May 13, 2019, 11:29pm UTC](https://discourse.processing.org/t/controlp5-radiobutton-question/11211 "2019-05-13T23:29:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![goosey](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@goosey](https://discourse.processing.org/u/goosey)
#### Post date: [May 13, 2019, 11:29pm UTC](https://discourse.processing.org/t/controlp5-radiobutton-question/11211/1 "2019-05-13T23:29:41Z")

</div>

Hello!

In I project using cp5, I want to display a list of toggles, each of which has a corresponding group of controllers.

Here is the relevant code:

```auto
cp5.addRadioButton("shape picker")
    .addItem("line", 1)
    .addItem("free draw", 2)
    .addItem("polygon", 3)
    .addItem("curve", 4)
    .addItem("free curve", 5)
    .addItem("ellipse", 6)
    ; 

for (Toggle t : cp5.getController("shape picker").getItems()){
    cp5.addGroup(t.getName()+" settings")
    ;
}

```

Basically, I want a settings menu for each mode described in the radio button initialization.

The error I run into is “the function getItems() does not exist”. And surely, when I look at the RadioButton Javadoc, both getItem(int) and getItems() are methods for the Toggle class. That is to say, I cannot find a method in the RadioButton class that returns the toggles that comprise it. Is there a way to access these toggles that I am missing?

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [May 14, 2019, 3:30am UTC](https://discourse.processing.org/t/controlp5-radiobutton-question/11211/2 "2019-05-14T03:30:24Z")

</div>

yes, just stay more close to the example!  
and please post running code ( besides your problematic command )

also i not understand why you want do a addGroup,  
as your RadioButton with addItem already is like a Group  
( meaning like it functions already as select one of n )

also what should the

```auto
+" settings"

```

do?

but you can add the whole  
RadioButton(s) to a group if you want.

i play this:

```auto
import controlP5.*;

ControlP5 cp5;
RadioButton r1;
Group g1;

void setup() {
  size(700, 400);

  cp5 = new ControlP5(this);
  r1 = cp5.addRadioButton("shape picker")
    .setPosition(100, 100)
    .setSize(20, 20)
    .addItem("line", 1)
    .addItem("free draw", 2)
    .addItem("polygon", 3)
    .addItem("curve", 4)
    .addItem("free curve", 5)
    .addItem("ellipse", 6)
    .addItem("triangle", 7)
    ; 

  g1 = cp5.addGroup("mysettings");
  g1.add(r1);

  for (Toggle t : r1.getItems()) {
    println(t.getName());
    //cp5.addGroup(t.getName()+" settings"); // but you did a addItem, why try a addGroup ? and add text " settings" ??
  }
}

void draw() {
  background(200, 200, 0);
}

void controlEvent(ControlEvent theEvent) {
  if (theEvent.isFrom(r1)) {
    print("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());
  }
}

```
