[controlP5]Two ScrollableLists

edited April 2016 in Library Questions

Hi. I'm in a project that involves two scrollableLists. I need the result of the first list to determine what will the results of the second one will be. the full congressmen list in on a cvs file, with name, party,origin state and vote status.

actually. i'm doing a parliamentary vote map. so the first sL is a state lists(27 states). the second scrollable list should be the state congressmen. so if i choose state 6 on the first, it should list all that state's congressmen on the second sL. actually i can retrieve all the data from the table and read it correctly with a state filter. what i cannot do is add these names to the second list.

how can do that?

void setup(){

    cp5 = new ControlP5(this);

        cp5.addScrollableList("dropdown")
          .setPosition(20, 40)
            .setCaptionLabel("ESTADO")
              .setSize(60, 200)
                .setItemHeight(25)
                  .setBarHeight(30)
                    .addItems(estado)
                      .setType(ScrollableList.LIST)
                        ;


        cp5.addScrollableList("dropdown2")
          .setPosition(100, 40)
            .setCaptionLabel("DEPUTADO")
              .setSize(300, 150)
                .setItemHeight(25)
                  .setBarHeight(30)
                      .setType(ScrollableList.LIST)
                        ;
   }

     void dropdown(int n) {
        String estado=cp5.get(ScrollableList.class, "dropdown").getItem(n).get("name").toString();
        println(estado);

        cp5.get(ScrollableList.class, "dropdown2").clear();

        for (TableRow row : table.findRows (estado, "estado")) {
          int depId=row.getInt("id");   
          String depNome=row.getString("nome");
          String depEstado=row.getString("estado");
          String depPartido=row.getString("partido");
          println(depId + " " + depNome + ": " + depEstado+"|"+depPartido);

        }
       // cp5.get(ScrollableList.class,"dropdown2").addItems(nomes);
      }
Sign In or Register to comment.