This is great - thanks. Geez, every time I try to do another iteration I get myself into trouble again. So, my next challenge / goal is to have the AL / NL selection drive which teams show up under the TEAM drop down. There are certain teams in the AL and certain teams in the NL. I added that content and an if statement, but it doesn't seem to work. Is this even possible - to have a drop down menu entry dictate what appears in another drop down? Code below. kevin PS - when you say "post code" before inserting, how do I do that?
import controlP5.*;
ControlP5 cp5;
String currentTeam = "";
String currentLeague = "";
void setup() {
size(1400, 800);
textFont(createFont("CenturyGothic", 30));
cp5 = new ControlP5(this);
cp5.setControlFont(new ControlFont(createFont("CenturyGothic", 12), 12));
DropdownList team = cp5.addDropdownList("Team").setPosition(100, 100).setSize(100, 600);
DropdownList league = cp5.addDropdownList("League").setPosition(300, 100).setSize(100, 600);
String[] ALteamNames = {
"BAL", "BOS", "CHW", "CLE", "DET", "KAN", "LAA",
"MIN", "NYY", "OAK", "SEA", "TAM", "TEX", "TOR"
};
String[] NLteamNames = {
"ATL", "XXX", "XXX", "XXX", "XXX", "XXX", "XXX",
"XXX", "XXX", "XXX", "XXX", "XXX", "XXX", "XXX"
};
// if AL Chosen
if (currentLeague == "AL") {
for (int i=0; i<ALteamNames.length; i++) {
team.addItem(ALteamNames[i], i);
}
//league.addItem("AL", 0);
//league.addItem("NL", 1);
//customize(team);
//customize(league);
}
// If NL Chosen
else {
for (int i=0; i<NLteamNames.length; i++) {
team.addItem(NLteamNames[i], i);
}
}
league.addItem("AL", 0);
league.addItem("NL", 1);
customize(team);
customize(league);
}
void draw() {
background(128);
text("currentLeague: " + currentLeague, 700, 300);
text("currentTeam: " + currentTeam, 700, 100);
}
void controlEvent(ControlEvent theEvent) {
if (theEvent.isGroup()) {
String listName = theEvent.getName();
String itemName = theEvent.getGroup().captionLabel().getText();
if (listName.equals("Team")) {
currentTeam = itemName;
} else if (listName.equals("League")) {
currentLeague = itemName;
}
}
}
void customize(DropdownList ddl) {
ddl.setBackgroundColor(color(190));
ddl.setItemHeight(30);
ddl.setBarHeight(30);
ddl.captionLabel().style().marginTop = 3;
ddl.captionLabel().style().marginLeft = 3;
ddl.valueLabel().style().marginTop = 3;
ddl.setColorBackground(color(60));
ddl.setColorActive(color(255, 128));
}