Using selectOutput

I seek to add a file browser to my application. I see that the selectOutput, and selectInput, classes were made for it. In this document for selectOutput:
I see constructor overloads that I cannot find documentation on. These are:

selectOutput(prompt, callback, file)
selectOutput(prompt, callback, file, callbackObject)
selectOutput(prompt, callbackMethod, file, callbackObject, parent)
selectOutput(prompt, callbackMethod, file, callbackObject, parent, sketch)

I cannot find any documentation for the file, callbackObject, parent, and sketch, parameters.

My guess is that the “file” parameter is the default directory the file browser starts in. I have no guess for what the callbackObject, parent, and sketch, parameters are there for, and how to use them. Where is complete documentation for the selectInput, and selectOutput, classes that include a description of those four right most optional parameters?

1 Like

If we invoke the overloaded version w/ just 2 parameters, we’ll get a null File file and a this Object callbackObject when it reaches the overloaded version w/ 4 parameters:

Then the overloaded version w/ 4 parameters invokes the 1 w/ 6 parameters, passing null for Frame parent and this for PApplet sketch:

Given selectOutput() is a method from class PApplet, the keyword this holds a reference for the current instance of it; which is our sketch.

It means by default the parameter String callback represents the name of some public void (File) method inside our sketch.

If we instead need for it to callback a method name belonging to some other class, we can use any overloaded version w/ 4 or more parameters, passing the instance of the target class as the argument for the parameter Object callbackObject.

1 Like