Dialog Box name and extention

When displaying a Dialog Box to save an item, is there a way to set the highlighted part so that it only covers the default name, and not the extension?

Bueller?

Would be nice if you posted in the platform used, instead of General. The answer depends on that as well.

Windows.

I just tested with the example at http://documentation.xojo.com/index.php/GetSaveFolderItem under Windows 10 with 2015R2.4, and it does exactly what you describe.

However, there is a way to position focus in such a control, which is to send keys Tab chr(9) or shift Tab chr(15), which can be achieved by the method posted at
Sendkey () function - General - Xojo Programming Forum .
It should work sending the key in a timer for instance one second after calling the dialog.

When you say it does what I describe, do you mean you’re seeing the same problem, or that this method works as I want it to?

As for your 2nd part, I’m not able to decipher when I need to do there. Seems like a hack with VB. Odd that XOJO doesn’t have this option built in, sense it’s standard on modern Windows apps these days.

Or if the extension of part of the highlighted text, it still puts the correct extension on it even if you overwrite it, like Office 2010,

The file name is selected.

Just look at the link I posted. VB has nothing to do with it, and it is not a hack.

You say the file name is selected. Does that include the extension? I need some clarity on what you’re trying to convey with this.

It’s Wscript. Seems VB-ish to me. As I mentioned, I’m not able to decipher it for my needs.

Dim f As FolderItem Dim fileStream as TextOutputStream f=GetSaveFolderItem(FileTypes1.Text,"MyFile.txt") If f <> Nil then fileStream=TextOutputStream.Create(f) fileStream.WriteLine Test text" fileStream.Close End if

All MyFile.txt is selected, including ‘txt’.

Post your code is you use something else.

I hate to tell you, but WScript is part of the standard Windows software. There is no hack when a method such as this is documented by Microsoft.

You may not be familiar enough with Xojo yet to apply what is posted. Maybe I should not have mentioned that method, since it is obviously unnecessary in this instance. Please disregard.

OK, so that’s exactly what I’m seeing. Not sure why you posted it. It seemed to be you were saying use GetSaveFolder Item instead of SaveAsDialog, but I couldn’t ascertain what you were seeing until now.

To reply to your original post, you could use a default name without any extension. Then you test the resulting folderItem name to see if it has an extension, and if the user did not add one (in this instance the default asc has been added by the dialog), add it yourself.

f=GetSaveFolderItem(FileTypes1.Text,"MyFile") If f <> Nil then if instr(f.name,".asc") > 0 then f.name = left(f.name, instr(f.name,".asc"))+"txt" end if

There is another way. The default text in FileTypes has a plethora of extensions, and the first one (asc) is added automatically. If you delete all that flurry and keep only .txt, that will be added automatically for you.

For Windows users who by default never see or know what an extension is, saving a plain name is probably much more natural.

I tired to add you code into a SaveasDialog (which I’m using) with no luck. If I don’t put an extension on the name, no extension is added.

[code] Dim Documents As FolderItem = SpecialFolder.Temporary.child(“AutoIT Maker”)
Dim f As FolderItem = Documents.Child(“Untitled.au3”)

Dim dlg as New SaveAsDialog
Dim dest as FolderItem

Dim txtType as New FileType
txtType.Name = “AutoIT Script”
txtType.Extensions = “au3”

dlg.InitialDirectory=SpecialFolder.Desktop
dlg.promptText=“Prompt Text”
dlg.SuggestedFileName=“Untitled.au3”
dlg.Title=“Save Script”
dlg.Filter=txtType
dest=dlg.ShowModal()
If dest <> Nil then
if instr(dest.name,".asc") > 0 then
dest.name = left(dest.name, instr(dest.name,".asc"))+“au3”
end if
dest.Delete
f.CopyFileTo(dest)
Else
End if[/code]

No need to test the extension.

Use a default name without extension, and it will be added automatically.

Also, you need to test if f is valid before trying to copy it.

[code] Dim Documents As FolderItem = SpecialFolder.Temporary.child(“AutoIT Maker”)
Dim f As FolderItem = Documents.Child(“Untitled.au3”)

Dim dlg as New SaveAsDialog
Dim dest as FolderItem

Dim txtType as New FileType
txtType.Name = “AutoIT Script”
txtType.Extensions = “au3”

dlg.InitialDirectory=SpecialFolder.Desktop
dlg.promptText=“Prompt Text”
dlg.SuggestedFileName=“Untitled”
dlg.Title=“Save Script”
dlg.Filter=txtType
dest=dlg.ShowModal()
If dest <> Nil and f<> nil and f.exists then
if dest.exists then dest.Delete
f.CopyFileTo(dest)
Else
End if[/code]

Hmmmmm…

It is not adding the extension when I save with just the name.

Strange.

If I put a system.debuglog after the dialog, I do get the extension :

dest=dlg.ShowModal() system.DebugLog dest.ShellPath

The debuglog appears in the lower part of the IDE when you click the third icon in the center bottom of it.

You can also put Break after the dialog, that will let you see the content of all variables.

No extension in the bebuglog either.

I’m on 2014 2.1

Your version is ancient now. Latest versions do not have this issue.

Here is the workaround :

dest=dlg.ShowModal() if instr(dest.name,"."+txtType.Extensions) = 0 then dest.name = dest.name+"."+txtType.Extensions end if

That works! Thank you very much!