Loading...
Logo
Processing Forum
Hello, I am attempting to use selectFolder() within an ImageLoader class I have created, but it is unable to find the callback function.

Copy code
  1. class ImageLoader {

  2. // vars, methods etc.

  3. void init() {
  4. selectFolder("Select a folder to process:", "folderSelected");
  5. }

  6. }


Main app:

Copy code
  1. ImgLoader images = new ImgLoader(3000);

  2. void setup() {
  3.   size(400,400);
  4.   images.init();



When running .init() in startup() { } I get:

folderSelected() could not be found

Any ideas how to reference this function, or is my logic just completely flawed?

Cheers

- Roo

Replies(1)

An example in this recent post below uses selectFolder():
http://forum.processing.org/topic/listing-last-10-modified-files-in-directory

And in that example, it's provided a function w/ the same name as its 2nd String parameter:
void folderSelected(File name) {}

For selectFolder() to invoke a method w/ an arbitrary name, it gotta know the reference
of the object that method belongs to.

Since selectFolder() doesn't ask for an object reference,
I believe it assumes it's the main sketch's instance itself.

Gotta do some further experiments here.
But I guess for a method to be invoked by selectFolder(), it ought to belong to the main sketch.
Just like other similar functions -> method("") and thread("").