Hello everyone! i’m a new on processing forum.
I make a Scrolablelist from ControlP5 library and I would like to change via code the selected item:
import controlP5.*;
import java.util.*;
ControlP5 cp5;
void setup() {
size(400, 400);
cp5 = new ControlP5(this);
List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
/* add a ScrollableList, by default it behaves like a DropdownList */
cp5.addScrollableList("dropdown")
.setPosition(100, 100)
.setSize(200, 100)
.setBarHeight(20)
.setItemHeight(20)
.addItems(l)
.setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
;
}
I try but not sure if it is possible. Add the following to cp5:
.setValue(1)
.open()
This sets the value display in the list when the list is close. Calling open forces to open the list. However, selecting it will be a bit trickier. Selection is tight to mouse events. You might need to override them. If this is your intention, you can look on previous posts related to overriding mouse events with controlP5 and see if you can find something that could use and try in your case.
articoloCliente = listFileNames(pathDataSet + slash + clienti[clienteSelezionato]); // read a list of Files
cp5.get(ScrollableList.class, "ARTICOLI").setLabel("ARTICOLI"); // reset the top label
cp5.get(ScrollableList.class, "ARTICOLI").setItems(articoloCliente); // change present list with <articoloCliente>
cp5.get(ScrollableList.class, "ARTICOLI").open(); // force <ScrollableList> open