enum FileDialog
Swift
enum FileDialog
Native "open"/"save" file picker.
The picker is LavaExplorer, run as LavaExplorer --choose=… — the same
file manager, with a bar along the bottom for the name and the answer, so
Open… in any Lava app looks like the desktop it is on. It is found at
LAVA_FILE_CHOOSER (a path to the binary), next to the running app's own
binary (every app in this package builds into one directory), or on
PATH, in that order. Without one, zenity — GTK's chooser — as before;
LAVA_FILE_CHOOSER=zenity asks for it outright.
It is a subprocess either way, for the reason zenity was: a picker is a window, and a client has one surface. The chosen paths come back through a file named on the command line rather than stdout, which an app is free to fill with anything.
Blocks the calling thread until the user picks or cancels, same as any
native modal dialog; call it from the main loop between frames, not from
a paint closure. Returns nil on cancel, on a platform with no backend,
or with no picker installed — callers should treat all three the same way
("no file chosen"), not surface them as distinct errors.
Sources/LavaUI/FileDialog.swift:23
Properties
nonisolated(unsafe) static var parentSurface: (() -> UInt32?)?
The calling window's compositor surface, set by LavaClient: the
picker opens as a dialog of it, centred over it and kept above it.
Nil in a windowed app, whose picker is a dialog of nothing.
Sources/LavaUI/FileDialog.swift:70
Methods
static func openFile(title: String = "Open File", filters: [Filter] = []) -> URL?
Asks for one existing file. nil when cancelled or no picker is available.
Sources/LavaUI/FileDialog.swift:40
static func openFiles(title: String = "Open Files", filters: [Filter] = []) -> [URL]
Asks for any number of existing files. Empty when cancelled or no picker is available.
Sources/LavaUI/FileDialog.swift:47
static func openFolder(title: String = "Choose Folder") -> URL?
Asks for one existing folder. nil when cancelled or no picker is
available.
Sources/LavaUI/FileDialog.swift:55
static func saveFile(title: String = "Save File", filters: [Filter] = [], defaultName: String? = nil) -> URL?
Asks where to save a file, suggesting defaultName. nil when cancelled
or no picker is available.
Sources/LavaUI/FileDialog.swift:61
Types
FileDialog.Filter struct
A named group of file types the picker can restrict itself to, such as "Images" with ["png", "jpg"].