you beat me to it
here is an example with buttons
// Demo for selectInput
//states
final int stateWaitForFile = 0; // consts
final int stateDone = 1;
final int stateBreak = 2;
final int stateWaitForButton = 3;
int state = stateWaitForButton; // current
String fileGlobal = "";
Table tableTest ;
// ----------------------------------------------------------------------------------------
void setup() {
size (1100, 700);
background(111);
}
void draw() {
//
// switch
switch (state) {
case stateWaitForFile:
// waiting until file has been selected
background(111);
text("Please choose a file. Hit Cancel to abort.",
33, 33);
// THE WAIT IS OVER
if (!fileGlobal.equals("")) {
state = stateDone;
// here you would load the table
tableTest = loadTable(fileGlobal);
//
} // if
break;
case stateDone:
// here you would have the table and display it
background(111);
text("File is there now: "
+fileGlobal, 100, 100);
showButtons();
text(tableTest.getColumnCount(), 30, height-177); //
break;
case stateWaitForButton:
background(111);
text("Please selecr a button.", 100, 100);
showButtons();
break;
case stateBreak:
background(111);
text("Window was closed or the user hit cancel.", 33, 33);
showButtons();
break;
default:
// error
println ("error 91");
exit();
break;
//
} // switch
//debug
fill(255);
text(state, 30, height-30);
} // func
// -----------------------------------------------------------------
// file handling
void fileSelected(File selection) {
//
// the 'callback' function.
//
if (selection == null) {
println("Window was closed or the user hit cancel.");
state = stateBreak;
} else {
println("User selected " + selection.getAbsolutePath());
fileGlobal = selection.getAbsolutePath();
} // else
}//func
// ----------------------------------------------------------------
// Input
void mousePressed() {
// check Buttons
if (state==stateDone||state==stateBreak||state==stateWaitForButton) {
if (dist(mouseX, mouseY, 133, 133) < 66) {
// reset / restart
fileGlobal="";
selectInput("Select a file (Cancel to abort):",
"fileSelected");
state=stateWaitForFile;
}//if
else if (dist(mouseX, mouseY, 233, 133) < 66) {
exit();
}//else if
} //if
//
} //func
//-------------------------------------------------------------------
//Tools
void showButtons() {
// set mode for text and rect
textAlign(CENTER, CENTER);
rectMode(CENTER);
// rects
noFill();
rect(133-5, 133+3, 84, 23);
rect(233-1, 133+3, 84, 23);
// text
fill(255);
text ( "Choose file", 133, 133);
text ( "Quit", 233, 133);
// reset
textAlign(LEFT);
rectMode(CORNER); // The default mode is rectMode(CORNER)
}//func
//