FolderItemDialog
From Xojo Documentation
The base class for the OpenDialog, SaveAsDialog, and SelectFolderDialog classes, which allow you to create customized open, save, and select folder dialog boxes.
Properties | ||||||||||
|
Methods | ||
|
Notes
Not all properties are available for all three subclasses of FolderItemDialog and some properties are not supported on Windows.
The following table clarifies the situation.
Property | Windows | Windows | Windows | macOS | macOS | macOS | Linux | Linux | Linux |
---|---|---|---|---|---|---|---|---|---|
OpenDialog | SaveAsDialog | SelectFolder | OpenDialog | SaveAsDialog | SelectFolder | OpenDialog | SaveAsDialog | SelectFolder | |
Top & Left | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
PromptText | ✓ | ✓ | ✓ | ✓ | |||||
Title | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
ActionButtonCaption | ✓ | ✓ | ✓ | ✓ | |||||
CancelButtonCaption | ✓ | ✓ | ✓ | ||||||
SuggestedFileName | ✓ | ✓ | ✓ | ✓ | |||||
Filter | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
InitialDirectory | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Examples
The following code opens a customizable open-file dialog box and presents the Documents or Home directory in the file browser. Only MIF files are listed. The file type passed to the Filter parameter was previously defined in a File Type Set called "TextTypes" in the File Type Sets Editor or via the FileType class.
Var f As FolderItem
dlg = New OpenDialog
#If Not TargetLinux Then
dlg.InitialFolder = SpecialFolder.Documents
#Else // open Home directory on linux
dlg.InitialFolder = SpecialFolder.Home
#Endif
dlg.Title = "Select a MIF file"
dlg.Filter = FileTypes1.mif //Defined as file type in FileTypes1.
f = dlg.ShowModal
If f <> Nil Then
// proceed normally
Else
// User Cancelled
End If
The following example opens a customized save-file dialog box and displays the contents of the "Documents" directory in the browser area.
Var f As FolderItem
dlg.InitialFolder = SpecialFolder.Documents
dlg.PromptText = "Prompt Text"
dlg.SuggestedFileName = "Suggested Filename"
dlg.Title = "Title Property"
dlg.Filter = FileTypes1.Text //defined as a file type in FileTypes1 File Type Set
f = dlg.ShowModal
If f <> Nil Then
// file saved
Else
//user canceled
End If
The following example opens a select folder dialog box and presents the contents of the "Documents" or "Home" directory on the user's startup volume in the browser:
Var f As FolderItem
dlg.ActionButtonCaption = "Select"
dlg.Title = "Title Property"
dlg.PromptText = "Prompt Text"
#If Not TargetLinux Then
dlg.InitialFolder = SpecialFolder.Documents
#Else // open Home directory on linux
dlg.InitialFolder = SpecialFolder.Home
#Endif
f = dlg.ShowModal
If f <> Nil Then
// use the folderitem here
Else
// user cancelled
End If
See Also
OpenFileDialog, SaveFileDialog, SelectFolderDialog classes.