I would like to remove some of the functionality of a Textfield
.
When the enter or return keys are pressed, the field becomes empty. I would like the value entered to stay within the field.
I have tried overriding the submit method but this hasn't done the job:
widthTopField = new Textfield(controlP5, "widthField"){
@ Override public Textfield submit(){
return this;
}
};
Demonstrates using .setAutoClear() to retain edit field contents after hitting return button. Field 1 is set to true and the other is set to false.
import controlP5.*;
ControlP5 cp5;
void setup() {
size(400,400);
PFont font = createFont("arial",18);
cp5 = new ControlP5(this);
cp5.addTextfield("Field 1")
.setPosition(40,50)
.setSize(200,40)
.setFont(font)
.setFocus(true)
.setColor(color(255))
.setAutoClear(true);
;
cp5.addTextfield("Field 2")
.setPosition(40,130)
.setSize(200,40)
.setFont(font)
.setAutoClear(false);
;
}
void draw() {
background(0);
}