CNewFileSelector ignoring type on OSX

A user interface toolkit mainly for audio plug-ins (VST, AudioUnit, etc).
Post Reply
f.berti
Posts: 24
Joined: Thu Nov 02, 2017 5:50 pm

CNewFileSelector ignoring type on OSX

Post by f.berti »

Hello,

I'm building a file selector using this code:

Code: Select all

loadFileSelector = CNewFileSelector::create(getFrame(), CNewFileSelector::kSelectFile);
    
if (loadFileSelector)
{
	loadFileSelector->setDefaultExtension(CFileExtension("JSON file", "json"));
	loadFileSelector->setTitle("Choose a sound bank file...");
	loadFileSelector->run(this);
	loadFileSelector->forget();
}
When the select file dialog appears on OSX (I'm testing it on 10.10, building for 10.7 target), I keep seeing all the files as selectable, while I was expecting to see only the file with the extension specified ("json" in this case) as selectable and the rest greyed out.

I did some debugging on macfileselector.mm and this block of code is getting executed:

Code: Select all

	
if (openPanel)
{
#if MAC_COCOA
	if (parentWindow)
	{
		setupInitalDir ();
		openPanel.allowedFileTypes = typesArray;
		remember ();
		[openPanel beginSheetModalForWindow:parentWindow completionHandler:^(NSInteger result) {
			openPanelDidEnd (openPanel, result);
			forget ();
		}];
	}
	
	...
Everything looks fine, I see the typesArray correctly containing the "json" string, but I'm still able to select all the files from the dialog window...
Am I missing something? Everything works as expected on Windows...

Thanks in advance,
Federico

Arne Scheffler
Posts: 373
Joined: Mon Jun 20, 2016 7:53 am

Re: CNewFileSelector ignoring type on OSX

Post by Arne Scheffler »

Hi Federico,
have you tried to add the UTI to the file extension ?

Code: Select all

CFileExtension("JSON file", "json", "application/json", 0, "public.json")
Cheers,
Arne

f.berti
Posts: 24
Joined: Thu Nov 02, 2017 5:50 pm

Re: CNewFileSelector ignoring type on OSX

Post by f.berti »

Arne Scheffler wrote:Hi Federico,
have you tried to add the UTI to the file extension ?

Code: Select all

CFileExtension("JSON file", "json", "application/json", 0, "public.json")
Cheers,
Arne
Same result, I can still select any type of file :(

Arne Scheffler
Posts: 373
Joined: Mon Jun 20, 2016 7:53 am

Re: CNewFileSelector ignoring type on OSX

Post by Arne Scheffler »

Can you post a screenshot of the file selector ? I'm not sure if what you see is just the way it works on macOS.

f.berti
Posts: 24
Joined: Thu Nov 02, 2017 5:50 pm

Re: CNewFileSelector ignoring type on OSX

Post by f.berti »

Here you go.
As you can see, all the files are selectable, regardless of the file type.
I'd like to filter out non-"json" files in order to help the user, like in Windows.
You do not have the required permissions to view the files attached to this post.

Arne Scheffler
Posts: 373
Joined: Mon Jun 20, 2016 7:53 am

Re: CNewFileSelector ignoring type on OSX

Post by Arne Scheffler »

OK, this indeed looks wrong. Did you check another host, just to make sure that it is not Reaper causing this ?
Other than that I've no clue, I'm using the file selector successfully in many projects.

Cheers,
Arne

f.berti
Posts: 24
Joined: Thu Nov 02, 2017 5:50 pm

Re: CNewFileSelector ignoring type on OSX

Post by f.berti »

Arne Scheffler wrote:OK, this indeed looks wrong. Did you check another host, just to make sure that it is not Reaper causing this ?
Damn, it works correctly in Logic and GarageBand... :x
Thanks for the tip, Arne!

Post Reply