When a save file dialog opens I want the suggestedname selected and the extension unselected (standard behavior in macOS). I read that to do this you set the dialog’s Filter property to the extension. But that’s not working for me. This is an example modified from the LR
Var dlg As New SaveFileDialog
dlg.SuggestedFileName = “Suggested Filename.txt”
dlg.Filter = “txt”
f = dlg.ShowModal
The entire SuggestedFileName is selected. I’ve played with endless variants with the same result (use a FileType.extension instead of a literal, use “.txt”, etc.) with the same result. The entire SuggestedFileName is selected.
Of course I could leave the extension out of the suggested name and add it back when the file is saved, but I want the user to be able to see it as visual feedback.
The most reliable way to work around this folder dialog bug is to define your file type as an object in code immediately before using it.
var ftTxt as new FileType
ftTxt.Name = "Plain Text"
ftTxt.Extensions = ".txt"
var dlg as new SaveAsDialog
dlg.Filter = ftTxt
dlg.SuggestedFileName = "Suggested.txt"
var ftResult as FolderItem = dlg.ShowModal
Thanks, Tim, but when I run your code the name is just Suggested (no .txt). I could do that of course by making SuggstedFilename = “Suggested”, but I do want .txt to be visible to the user.
It’s not just a visual indication, as some behaviours would also break (like the “There’s already an item named “file.txt”. Would you want to replace it?” message would no longer appear when appropriate), so you’d probably not want to do that alone.
Wow… What’s the purpose of that? They try to hide the extension to make it appear like when it was not needed at all in MacOS classic?
Is there still something logical in later versions of MacOS?
I’m happy to stay behind, on Mojave, when I see what they’re doing now. OTH, I’ve never read this behaviour before.
@Greg_O_Lone The problem I posted at the beginning isn’t one of FileTypes. It’s that setting the filter property to a particular FileType in a Save (not Open) FileDialog simply hides the extension. What I was after was the standard (or at least extremely common) macOS behavior that the name is selected and the extension is shown but not selected. If that’s possible a blog post would be most welcome.