Can only select files and not directories

My program scans a file OR directory and analyzes it’s properties, however the OpenFileDialog in Xojo
on Linux seems to only be able to select files. Not sure if this is a flaw of Xojo or the system file chooser. It could also be me, if below looks wrong please let me know!
Else is there a way to make Xojo pick a file OR folder? Thank you!

Public Function SelectTargetDialog(startAt as String) As FolderItem
  Var selectedItem As FolderItem
  
  Var dlg As New OpenFileDialog
  dlg.InitialFolder= SpecialFolder.UserHome
  dlg.AllowMultipleSelections= False
  
  If(startAt.Lowercase="home") Then
    dlg.InitialFolder = SpecialFolder.UserHome
  ElseIf(startAt.Lowercase="docs") Then
    dlg.InitialFolder = SpecialFolder.Documents
  ElseIf(startAt.Lowercase="pics") Then
    dlg.InitialFolder = SpecialFolder.Pictures
  ElseIf(startAt.Lowercase="sys") Then
    dlg.InitialFolder = SpecialFolder.Caches
  Else
    dlg.InitialFolder = SpecialFolder.UserHome
  End
  
  Var f As FolderItem= dlg.ShowModal
  
  For Each file As Folderitem In dlg.SelectedFiles
    selectedItem= file
  Next
  Return selectedItem
  
End Function

On Linux Mint 21.3 with Cinnamon

If you want to select a folder, you must use the SelectFolderDialog class:

var dlg as new SelectFolderDialog
var result as FolderItem = dlg.ShowModal
2 Likes

I’m assuming this will select only folders, is there an option for select anything you want, File OR folder? In one dialog so a “browse” button could trigger it.

There may be in MBS, but not built-in that I’m aware of. I think the last time I built an interface for selecting files and folders, I provided a list UI with a button for adding files and another for adding folders.

Ah darn, good to know though! If I come up with something I will put it here but you pointing me to that function is a good start, thank you!

Happy to help, as little as I was able.

What’s first to be known is whether the OS provides a dialog for selecting both. Last time I was aware (around ten years ago), MacOS was the only OS among the three Xojo supports to provide such a feature.

Yeah I thought there was a possibility it was a system thing. I know Windows could do it but wasn’t sure about Linux. Haven’t ran into it until now but it’s my favorite platform.