Hi,
the maximum number of elements shown in the dropList (when expanded) seems to be 10.
Is there a way to increase the number (I want 20 )?
Thanks
Hey, I did a bit of searching and found this specific page on the G4P website: G4P (GUI for Processing): g4p_controls.GDropList Class Reference
Most specifically:
g4p_controls.GDropList.GDropList | ( | PApplet | theApplet , |
---|---|---|---|
float | p0 , | ||
float | p1 , | ||
float | p2 , | ||
float | p3 , | ||
int | viewListMaxSize | ||
) |
With a description reading:
Create a drop down list component with a specified list size.
So I hope this is what you’re looking for? Please try it out and let me know. Thanks!
EnhancedLoop7
Yes you can set the maximum number of items to be displayed when creating the droplist. Just like this
import g4p_controls.*;
GDropList dl;
void setup() {
size(400, 600);
String[] items = new String[30];
for (int i = 0; i < items.length; i++) {
items[i] = "" + (i+1);
}
dl = new GDropList(this, 10, 10, 120, 400, 20);
// ^ number of items to show
dl.setItems(items, 3); // Start with '4' selected
}
void draw() {
background(255);
}
OK first up: I used the G4P GUI builder tool for this because I have a lot of buttons and checkboxes and it’s easier to have them visually layed out for me.
The tool limits me (for whatever reason as I now found out) to 10 lines maximum. That’s why I posted this.
As of now it works fine, thanks to you guys. But I now have to change 2 values of this:
namely p3 (height when extended) and viewListMaxSize every time I open and close the tool.
I tried putting the creation of the dropList a second time directly behind the createGUI() but it doesn’t show anything then… :
createGUI();
datasets_dropList = new GDropList(this, 1460, 40, 420, 660, 20); //660 and 20 are the values I want
datasets_dropList.setItems(loadStrings("list_478498"), 0);
datasets_dropList.setLocalColorScheme(GCScheme.SCHEME_8);
datasets_dropList.addEventHandler(this, "datasets_dropList_click");
Is there a way to make it so I don’t have to change the values every time?
I don’t know why I limited it to 10, it probably made sense when I created GUI Builder. I will certainly change it for the next release but that doesn’t help you at the moment.
Sorry I can’t think of a sensible workaround.
I am assuming you are in the development / testing phases, can you not wait until you are ready to deploy and then modify the code?