selectOutput feature

Dear Kevin,
thank you for your suggestion. I modified the code:

int status;

void setup() {
  size(400, 400);
  status=0;
}

void draw() {

  if (mouseX >= width/2 && mousePressed) {
    if(status==0) {
      status=1;
      selectOutput("Select a file to write to:", "fileSelected");
    }
  }
}

void fileSelected(File selection) {
  status=0;
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    println("User selected " + selection.getAbsolutePath());
  }
}

The status variable is set before open the file selection window.
It works but the system varaible mousePressed remains always true…
How to reset it ?
Had you a similar problem ? How did you fix it ?
Thank you very much for your help and cooperation.
regards