We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone,
I have a little problem with my programme.
I would like to control if the text in the textfield is good or not but it doesn't work.
I can get the text in the textfield but when I want to check if it's good it doesn't work.
Some one has a solution for me please?
The code is here :
String Reponse = "oui";
import controlP5.*;
ControlP5 cp5;
void setup() {
size(700,400);
PFont font = createFont("arial",20);
cp5 = new ControlP5(this);
cp5.addTextfield("input")
.setPosition(20,100)
.setSize(200,40)
.setFont(font)
.setFocus(false)
.setColor(color(255,0,0))
;
cp5.addBang("clear")
.setPosition(240,170)
.setSize(80,40)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
;
textFont(font);
}
void draw() {
background(0);
fill(255);
text("Ecrivez votre réponse ici",20,90);
text(cp5.get(Textfield.class,"input").getText(), 360,130);
if(cp5.get(Textfield.class,"input").getText() == Reponse){
text("Vrai",20,20);
}
}
public void clear() {
cp5.get(Textfield.class,"input").clear();
}
thank you
Answers
edit post, highlight code, press ctrl-o to format
what do you expect, what happens instead?
Sorry i didn't know how to highlight the code thank you
I would like to know if the text in the text filed is the same word that a preload text in the program (for example in my program i would like to know if in the text field the word is the same that the string reponse
https://Processing.org/reference/String_equals_.html
Thank you very much it works.
But I have another problem.
As i want write in french in the textfield I need to use symbol like (ê or ë) but it's not possible, it write befor ¨ and e after.
Someone have an idea?
I use the library ControlP5