We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I use this processing function for saving data over a file menu inside a class: selectInput("Select a file to process:", "fileSelected");
but triggering the corresponding function "fileSelected" in the same class gets the error message: "fileSelected could not be found"
If I put the function fileSelected inside the mainTab of Processing the code works. Why this function cannot be found?
void fileSelected(File selection) { if (selection == null) { println("Window was closed or the user hit cancel."); } else { //String filename = String [] beispiel = {"User selected ",selection.getAbsolutePath(), " ..."}; saveStrings(selection.getAbsolutePath()+".txt", example);
Win7, 64bit, P3
Answers
B/c selectInput() only knows about sketch's PApplet reference.
Your other classes aren't PApplet!
Perusing selectInput()'s reference, there are other overloaded options w/ more parameters:
https://processing.org/reference/selectInput_.html
I guess callbackObject refers to an instance of the class which parameter callback belongs to.
Worth a try I daresay... 8->
Thanks! I tried it with
public void selectInput("Select a file to process:", "fileSelected", null, this);
and get the error: savePositions() must be public. Then I prepended "public" to the referencing method "fileSelected" but still the same.As i understand callbackObject is "this" (the class). How could i use the arguments "parent and sketch" from selectInput? parent: "null" sketch: "name of sketch"?
I am stuck. No idea how to get this to function?
Thanks GoToLoop. Your answer helped me to understand this problem. But i do not see a solution. So I will look for a workaround without selectInput.
PDE's pre-processor already prefixes all methods & fields w/o some access level keyword w/
public
.The only exceptions are
class
interface
. Solution: prefix your class w/public
. :-BIt works. my previous judgment was a little rash. Thanks a lot GoToLoop!