selectOutput() called from keyPressed() failing
Answered
- Need more info
- Answered
- Working on it
in
Programming Questions
•
3 years ago
Here is some example code which displays the error:
void setup() {
size(250, 250);
print("before setup() selectOutput() runs\n");
selectOutput(); //even with this line removed, the other selectOutput() causes a problem
print("after setup() selectOutput() runs\n");
}
void draw() {
background(0);
rect(mouseX, mouseY, 10, 10); //this helps demonstrate the program ceasing to function
}
void keyPressed() {
print("before keyPressed() selectOutput() runs\n");
selectOutput();
print("after keyPressed() selectOutput() runs\n");
}
In my full code, I'm catching a particular key to perform a Save As... function. When the selectOutput() during setup() runs, all is well. When the selectOutput() called by the pressed key runs, the dialog appears, you can select a file, but upon pressing Save, the sketch freezes permanently.
Any thoughts?
void setup() {
size(250, 250);
print("before setup() selectOutput() runs\n");
selectOutput(); //even with this line removed, the other selectOutput() causes a problem
print("after setup() selectOutput() runs\n");
}
void draw() {
background(0);
rect(mouseX, mouseY, 10, 10); //this helps demonstrate the program ceasing to function
}
void keyPressed() {
print("before keyPressed() selectOutput() runs\n");
selectOutput();
print("after keyPressed() selectOutput() runs\n");
}
In my full code, I'm catching a particular key to perform a Save As... function. When the selectOutput() during setup() runs, all is well. When the selectOutput() called by the pressed key runs, the dialog appears, you can select a file, but upon pressing Save, the sketch freezes permanently.
Any thoughts?
1