# G4P selectInput filter problem

**URL:** https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169
**Category:** Libraries
**Created:** [August 10, 2020, 3:26pm UTC](https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169 "2020-08-10T15:26:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gyula](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gyula](https://discourse.processing.org/u/gyula)
#### Post date: [August 10, 2020, 3:26pm UTC](https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169/1 "2020-08-10T15:26:41Z")

</div>

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

```auto
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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/deac34081fbf989e58aa7ca8099e26012cbac8be.png)

If I click on the “Objects of type” drop-down list no filter choices are diplayed:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fcbebe5c4e8709d1daab5312e2a030bf620ac367.png)

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

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [August 10, 2020, 5:34pm UTC](https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169/2 "2020-08-10T17:34:03Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

### Author: ![gyula](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gyula](https://discourse.processing.org/u/gyula)
#### Post date: [August 11, 2020, 9:33am UTC](https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169/3 "2020-08-11T09:33:43Z")

</div>

Thank you, Peter.

> [@quark](#):
>
> 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.

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

```auto
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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0f69e616f1791436753027bfc9764a1dc6fe79c3.png)

Now if I add your modification,

```auto
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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f68ef76cdb7d6faca0304447563569f7c45fd7f9.png)

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

> [@quark](#):
>
> Finally please try the example that comes with the library - it worked for me on OSX.

My original _minimal working example_ is just a stripped-down version of your **G4P\_Dialogs** example. 😉

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [August 11, 2020, 1:19pm UTC](https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169/4 "2020-08-11T13:19:30Z")

</div>

> [@gyula](#):
>
> That is, until I omit the startFolder parameter.

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.

---

<div class="post-metadata">

### Author: ![gyula](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gyula](https://discourse.processing.org/u/gyula)
#### Post date: [August 11, 2020, 3:14pm UTC](https://discourse.processing.org/t/g4p-selectinput-filter-problem/23169/5 "2020-08-11T15:14:32Z")

</div>

OK, thanks a lot again!
