SaveFileDialog single click double click difference

I was doing some tests for: CopyTo

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.

SaveFileDialogTest.xojo_binary_project.zip (16.9 KB)

Anyone else?

macOS 13.6.8, Xojo 2024r2.1

Using the ‘FolderItem Dialogs’ example that comes with Xojo you can see the problem:

single click (no replace warning)

image

double click

image

image

Example:

FolderItemDialog.xojo_binary_project.zip (29.2 KB)

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:
image

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:

@Arnaud_N or someone else, can you follow this steps and confirm/deny if you get the same?

I used macOS 13.6.8 and Xojo2024r2.1 yesterday with the same results.
Now I’m using a different computer with macOS 14.6 and Xojo2024r2.

Thanks.

Try my dialogs on GitHub. That’ll tell you if this is an Apple or a Xojo bug.

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.

I don’t have the link at hand, can you share?

1 Like

@Greg_O thank you.

With your code, if I single click XojoTest.PDF it shows XojoTest.PDF at top and works correctly
image

Xojo SaveFileDialog only shows the name without extension no matter if I single click or double click.

Can you confirm that this is a Xojo bug then?

Strange that is not a big deal for others.

Eh, no, I’m getting this:
image

Double-clicking the file doesn’t do anything (beyond putting the file name to the name field).
Mac OS 14.6.1 here, and Xojo2024r2.1.

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

Maybe my system is set to hide extensions and yours not (or viceversa).

I remember Xojo having problems because of this.

Mine is set to always show extensions.

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.

2 Likes