NSSavePanelMBS allowing any file type and not showing the extension


I’d like an export dialog to allow 5 file types (png, jpg, tif, bmp and gif). Currently, the dialog doesn’t visually append the extension to the filename, although my code specifically sets it.
The “Show extension” checkbox is hidden and I can’t make it visible, even with the appropriate call (MBS).
Also, whatever extension I add from within the dialog is accepted; the extension is added to the result (e.g. I enter “untitled.xyz” and the file is named “untitled.xyz.png”).
Looks like the “Show extension” checkbox is the culprit, but I can’t make it showing…

Here’s my code:

dim i As Integer
dim s As NSSavePanelMBS

s=new NSSavePanelMBS
s.setAllowedFileTypes Array("PNG","JPG","TIF","BMP","GIF")
s.Message="Select target file:"
s.NameFieldLabel="Export to:"

Any idea?

Let me check. The Show call is not needed and should be removed.

Please add this to show extension:

s.isExtensionHidden = false

and I would suggest to use

s.setAllowedFileTypes Array("public.image")

to allow all image types.

If you like to get a popup to select file type, you may need to add an accessory view.

A small problem remains, though: if the “Show extension” checkbox would be visible as it should, the isExtensionHidden setting would override the user’s last choice. But, well, I still can’t make it showing…
Is canSelectHiddenExtension broken?

Thanks for the suggestion, but I only support built-in file types for now (the 5 ones I’ve mentioned earlier).

Yes… Reminds me how it failed 10 years ago, for my first attempt…

Thank you.