processingcontrol-p5

ControlP5 Scrollable list start closed


Well i made an scrollable list in processing with the ControlP5 library. I need an dropdown and the Dropdown has a lot of deprecated functions in it and there they say this is the way to do it know.

The problem I have is that whenever I run the sketch the scrollable list starts folded out (not just the bar but all the options out).

I initialize the scrolldown list like this

 controlP5.addScrollableList("dropdown")
 .setPosition(0, 0)
 .setSize(200, 100)
 .setBarHeight(10)
 .setItemHeight(10)
 .addItems(l)     
 .setType(ScrollableList.DROPDOWN) 
 ;

Thanks in advance


Solution

  • You can set some default 'preselected' option

    .setValue(1)
    

    Or to fold in all options you can set inherited method setOpen() so your set up will looks like this

    cp5.addScrollableList("dropdown")
         .setPosition(100, 100)
         .setSize(200, 100)
         .setBarHeight(20)
         .setItemHeight(20)
         .addItems(l)
         .setType(ScrollableList.DROPDOWN)
         .setOpen(false)                      //false for closed
         ;
    

    Hope it helps to achieve what you want because I'm not sure from your Q.