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

KeyPressed BACKSPACE and delete just one shape

$
0
0

Hi there again, this time I need a little help: I've create a code for a "generative" logo (it's at the start so is not complete), and I want that while pressing one time the BACKSPACE I can go back just for one shape. Now like I have my code, when I press Backspace it delete all.

I leave the code here, thanks !

    import controlP5.*;

    ControlP5 cp5;

    String textValue = "";
    String val;

    void setup() {
       size(700,800);

      PFont font = createFont("arial",20);

      cp5 = new ControlP5(this);

      cp5.addTextfield("INPUT")
         .setPosition(width/2-100,600)
         .setSize(200,40)
         .setFont(font)
         .setFocus(true)
         .setColor(color(255,255,255))

         ;

      textFont(font);
      background(0);
      noStroke();
    }
    void draw() {


      if (keyPressed) {

        if (key == 'o' || key == 'O') {
          fill(205, 152, 59, 100);
          ellipse(width/2, height/2, 50, 50);
        }

          if (key == 'b' || key == 'B') {
            fill(20, 84, 42, 100);
            rectMode(CENTER);
            rect(width/2, height/2, 50, 50);
          }
        }
        if (key == BACKSPACE) {    //This reset all, I want to reset just the last one shape
      background (0);
    }

    val = cp5.get(Textfield.class,"INPUT").getText();
     println(val.length());

    }

Viewing all articles
Browse latest Browse all 2896

Trending Articles