Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

I can't control when the response in the textfield.

$
0
0

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


Viewing all articles
Browse latest Browse all 2896

Trending Articles