exit extended PApplet/ second window

edited April 2017 in Library Questions

I'm using processing 3.3. Basically this code opens a save window when "g" is pressed. You type the "name" and and "notes" and click on the save button so it appears on the main window. What I want is to be able to close the second window after clicking "save" and, if possible, when the second window opens i want it to open over the main window and not behind like it's doing. I've searched a lot and all the answers for this kind of problem don't work or the functions suggested are for preview versions of processing. Thank you for all the help

import controlP5.*;
ControlP5 caixas;
String caixa1;
String caixa2;
String texto1;
String texto2;
Save cf;

void settings() {
  size(400,400,P3D);
}

void setup(){
}
void keyPressed() {
  if (key == 'g') {
  cf = new Save(this, 800, 800);
}
}

void draw() {
  background(0);
  text("texto 1: " + texto1 + "\ntexto 2: " + texto2,50,50);
}

class Save extends PApplet {

  int w, h;
  PApplet parent;
  ControlP5 cp5;

  public Save(PApplet _parent, int _w, int _h) {
    super();   
    parent = _parent;
    w=_w;
    h=_h;
    PApplet.runSketch(new String[]{this.getClass().getName()}, this);
  }

  public void settings() {
    size(w,h);
  }

  public void setup() {
  caixas = new ControlP5(this); 

  caixas.addTextfield("Name").setPosition(20, 100).setSize(200, 40);

  caixas.addButton("Save").setPosition(20,60).setSize(100,40);

  caixas.addTextfield("Notes").setPosition(20, 170).setSize(200, 40);

  }

  void draw() {
    background(40);
  }

  public void controlEvent(ControlEvent theEvent) {
    texto1 = caixas.get(Textfield.class,"Nome").getText();
    texto2 = caixas.get(Textfield.class,"Notas").getText();
// HERE THE FUNCTION OR ANYTHING TO MAKE IT CLOSE
  }
}

Answers

Sign In or Register to comment.