We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello. Basically I'm getting outputs from key pressed buttons and I also want to have textfields. How do I make sure that when I'm writing on a textfield I don't get the outputs from the main code. I started with the code like this and I think the problem is I don't know how the function isFocus() works. Onoff is never getting true
import controlP5.*;
boolean onoff = false;
ControlP5 cp5;
void keyPressed() {
}
if ((key == 'a') && (onoff == false)) {
//Do something normally
}
}
cp5 = new ControlP5(this);
cp5.addTextfield("input_1")
.setPosition(20, 40)
.setSize(200, 40)
Textfield tf = (Textfield) cp5.getController("input_1");
if (tf.isFocus() == true) {
onoff=true;
}
else {
onoff=false;
}
Answers
Try this code. You are missing the draw and setup functions which are needed for controlP5 to be able to have that iteractive behavior that you are looking for. Check this link for more info: https://processing.org/reference/draw_.html
Kf
Thank you very much. I only posted part of the code so it would be easier. Problem was with the definition of "tf". I can know write without interfering with the commands