G4P selectInput filter problem

I cannot get the G4P.selectInput() filter parameters working. Here’s a simple sketch:

import g4p_controls.*;
String fname = G4P.selectInput("Input Dialog", "png,gif,jpg,jpeg", "Image files", sketchPath());
println( fname);

And the dialog window that appears:
image

If I click on the “Objects of type” drop-down list no filter choices are diplayed:
image

This is on Win7, 32-bit, Processing 3.5.3, G4P 4.3.5.

It would have been more useful if you had used the dialog to navigate to a folder that contained a mixture of files so we could see if the filter was being applied even if it doesn’t appear in the list of filters.

Try this modification which will use standard Java dialog rather than the OS native dialogs and see what happens.

import g4p_controls.*;
PApplet.useNativeSelect = false;
String fname = G4P.selectInput("Input Dialog", "png,gif,jpg,jpeg", "Image files", sketchPath());
println( fname);

Finally please try the example that comes with the library - it worked for me on OSX.

Thank you, Peter.

Fair enough, but I wanted the example to work for anyone. Here’s a slightly modified version that still shows the problem:

import g4p_controls.*;
createOutput("image1.png");
createOutput("image2.jpg");
String fname = G4P.selectInput("Input Dialog", "png,gif,jpg,jpeg", "Image files", sketchPath());
println( fname);

image

Now if I add your modification,

import g4p_controls.*;
PApplet.useNativeSelect = false;  // <--- quark's modification
createOutput("image1.png");
createOutput("image2.jpg");
String fname = G4P.selectInput("Input Dialog", "png,gif,jpg,jpeg", "Image files", sketchPath());
println( fname);

I get this (although with no option for “All files”):

image

So the modification does help. That is, until I omit the startFolder parameter. Then the sketch crashes with a NullPointerException at the selectInput() method.

My original minimal working example is just a stripped-down version of your G4P_Dialogs example. :wink:

This is a bug in G4P so if you don’t want to set the start folder use an empty string for the folder like this.
G4P.selectInput("Input Dialog", "png,gif,jpg,jpeg", "Image files", "");

The bug will be fixed for the next release of G4P.

With regard to showing the All Files filter when you use selectInput with a filter, I need to think how best to implement.

OK, thanks a lot again!