like @Kevin suggested, could move it to mousePressed
//_________________________________________________________________
void setup() {
size(100, 100);
}
//_________________________________________________________________
void draw_menu() {
fill(255);
rect(50, 80, 49, 19);
fill(0);
textAlign(CENTER, BOTTOM);
text("File", 75, 97);
}
//_________________________________________________________________
void draw() {
background(200, 200, 0);
draw_menu();
}
//_________________________________________________________________
void mousePressed() {
if ( overRect(50, 80, 50, 20) ) selectOutput("Select a file to write to:", "fileSelected");
}
//_________________________________________________________________
void fileSelected(File selection) {
if (selection == null) println("Window was closed or the user hit cancel.");
else println("User selected " + selection.getAbsolutePath());
}
//_________________________________________________________________ mouse position over rectangle yes/no
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) return true;
else return false;
}