and I can reproduce that if I single click a destination file (dialog) in the Downloads folder, the file is not removed and a new file without extension is created.
If I instead double-click a destination file (dialog) then the file is removed and the database file is created with the name and extension. I get the overwrite warning dialog.
Double-clicking doesnât do anything in the save as dialog Iâm getting. Are you double-clicking on the file itself (what I tried) or thereâs another thing to double-click on?
If youâre using an Open file dialog instead (where double-clicking chooses the file), then single-clicking shouldnât even dismiss the dialog, hence the difference of behaviour the steps you provided produce.
Iâm sorry my information was not clear. Letâs try again step by step:
1- create a file called XojoTest.PDF in your Desktop (assuming you use a Mac)
2- run FolderItemDialog.xojo_binary_project
3- click SaveAsDialog
4- expand the dialog to show the Desktop folder contents like this
5- single click on XojoTest.PDF
6- click save it!, you should get the path that ends with XojoTest without .PDF like this:
7- click SaveAsDialog again
8- now double click XojoTest.PDF (single vs double click is just for the first time you select a file)
9- now you will see a Replace warning dialog, click Replace
10- now the path will end with the full name (including extension) XojoTest.PDF like this:
Itâs also worth mentioning that how you create the initial file and what your FileType in Xojo look like might matter because of the underlying Uniform Type Identifiers.
Also which path are you looking at to determine what you got back? ShellPath or NativePath? Or are you looking at Name or DisplayName? It matters depending on what your settings are in Finder even in the Xojo debugger.
Iâm using the Folder Item Dialogs sample that comes with Xojo, the sample uses NativePath:
SelectedFolderItemLabel.Text = file.NativePath
with 1 click on destination file it shows the file name without extension, doing double click on destination file it shows the complete name with extension.
my dialog has an option of whether or not to show file extensions (ExtensionHidden) by Xojo hid/omitted that and the ability for the user to show them, so itâs a bug, an oversight or a side effect of Xojo-fication.
Unfortunately, SaveAsDialog doesnât have a Handle property so you canât use declares to solve the problem on that control.
The filter is not a file type, however.
You do not specify a file extension⊠isnât that the issue?
Change your code to read like this:
Var dialog As SaveFileDialog
Var file As FolderItem
// Create the dialog (does not actually show it)
dialog = New SaveFileDialog
// The filter is what type of file you are saving (for cosmetic purposes)
// The filters are defined in the File Types dialog
// inside the edit menu
Var textType As New FileType
textType.Name = "text/plain"
textType.Extensions = "txt" '<< this is important
dialog.Filter = textType
// The OpenDialog class supports custom promptsâŠ
dialog.PromptText = "Here's where the prompt goes"
// âŠand custom title's
dialog.Title = "This is the Title"
// Set the suggested file name
dialog.suggestedFileName="MyFile 1"
//etc
And youâre right: if I turn off this setting in the Finderâs preferences, the save dialog behaves differently. It already starts to differ when you single-click an item in the dialog: with âShow all filename extensionsâ turned on, selecting an item puts the whole file name, including its extension, in the name field; with the setting set to off, only the file name without the extension is put in the name field.
At that point, the next steps work as they should: if the name contains the extension, the dialog asking âdo you want to replace the existing item?â shows, otherwise not (since the existing item has the extension).
Now, I have no time now to check whether itâs a bug related to Xojo or the OS/other apps.