Array input field

I have a question about input fields(I’m using the ones from controlp5) and was asking myself if you can have it so, that every entry in that field are integers and also added to an array. Thank you for your help

Edit: As my project is a decoder, it would have to be editable with a keyboard.

Hello,

You can use the function yourString.split("") to parse the input string of your text field and then convert each string number into integers with Integer.parseInt(yourString).

Here is the complete example (adapted from the ControlP5 Textfield example:

import controlP5.*;
import java.util.Arrays;

ControlP5 cp5;
int[] arrayTextField;

void setup() {
  size(700,400);
  
  PFont font = createFont("arial",30);
  
  cp5 = new ControlP5(this);
  
  cp5.addTextfield("input")
     .setPosition(20,100)
     .setSize(200,40)
     .setFont(font)
     .setFocus(true)
     .setColor(color(255,0,0))
     ;
}

void draw() {
  background(0);
}

public void input(String theText) {
  //Splitting the numbers
  String[] splittedText = theText.split("");
  arrayTextField = new int[splittedText.length];
  
  //Inserting them into the array
  for(int i=0;i<splittedText.length;i++){
    arrayTextField[i] = Integer.parseInt(splittedText[i]);
  }
  
  //Printing the array
  println(Arrays.toString(arrayTextField));
}

Hey There!

There are different types that the things can be in the field :
http://www.sojamo.com/libraries/controlP5/reference/

In textfieldInput