We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So basically i want my sketch to remember what the last ten buttons are that have been clicked. I will see later on if i can make it so that it only prints the last 10 items added to the array but first i need to know how to add a string of text to a String array on buttonClick.
If i run the following sketch and press ENTER i get null in the console.
String[] buttons;
String displayButtons;
void setup(){
buttons = new String[3];
displayButtons = join(buttons, " : ");
}
void draw(){
}
void keyPressed() {
if ((key=='1')) {
buttons[0] = "You pressed button one";
}
if ((key=='2')) {
buttons[1] = "You pressed button two";
}
if ((key==ENTER)) {
printArray(displayButtons);
}
}
Answers
You are already storing the strings in the right way, the problem is only that you print a string that you created in setup() instead of printing the contents of your button-array. Try this:
@benja thanks for your answer, after some research it got me on my way :)