pub struct FileDialogBuilder(_);
dialog
only.Expand description
The file dialog builder.
Constructs file picker dialogs that can select single/multiple files or directories.
Implementations
sourceimpl FileDialogBuilder
impl FileDialogBuilder
sourcepub fn add_filter(self, name: impl AsRef<str>, extensions: &[&str]) -> Self
pub fn add_filter(self, name: impl AsRef<str>, extensions: &[&str]) -> Self
Add file extension filter. Takes in the name of the filter, and list of extensions
sourcepub fn set_directory<P: AsRef<Path>>(self, directory: P) -> Self
pub fn set_directory<P: AsRef<Path>>(self, directory: P) -> Self
Set starting directory of the dialog.
sourcepub fn set_file_name(self, file_name: &str) -> Self
pub fn set_file_name(self, file_name: &str) -> Self
Set starting file name of the dialog.
sourcepub fn set_parent<W: HasRawWindowHandle>(self, parent: &W) -> Self
pub fn set_parent<W: HasRawWindowHandle>(self, parent: &W) -> Self
Sets the parent window of the dialog.
sourceimpl FileDialogBuilder
impl FileDialogBuilder
sourcepub fn pick_file<F: FnOnce(Option<PathBuf>) + Send + 'static>(self, f: F)
pub fn pick_file<F: FnOnce(Option<PathBuf>) + Send + 'static>(self, f: F)
Shows the dialog to select a single file. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.
For usage in other contexts such as commands, prefer Self::pick_file
.
Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("failed to build tauri app")
.run(|_app, _event| {
FileDialogBuilder::new().pick_file(|file_path| {
// do something with the optional file path here
// the file path is `None` if the user closed the dialog
})
})
sourcepub fn pick_files<F: FnOnce(Option<Vec<PathBuf>>) + Send + 'static>(self, f: F)
pub fn pick_files<F: FnOnce(Option<Vec<PathBuf>>) + Send + 'static>(self, f: F)
Shows the dialog to select multiple files. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.
Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("failed to build tauri app")
.run(|_app, _event| {
FileDialogBuilder::new().pick_files(|file_paths| {
// do something with the optional file paths here
// the file paths value is `None` if the user closed the dialog
})
})
sourcepub fn pick_folder<F: FnOnce(Option<PathBuf>) + Send + 'static>(self, f: F)
pub fn pick_folder<F: FnOnce(Option<PathBuf>) + Send + 'static>(self, f: F)
Shows the dialog to select a single folder. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.
Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("failed to build tauri app")
.run(|_app, _event| {
FileDialogBuilder::new().pick_folder(|folder_path| {
// do something with the optional folder path here
// the folder path is `None` if the user closed the dialog
})
})
sourcepub fn pick_folders<F: FnOnce(Option<Vec<PathBuf>>) + Send + 'static>(
self,
f: F
)
pub fn pick_folders<F: FnOnce(Option<Vec<PathBuf>>) + Send + 'static>(
self,
f: F
)
Shows the dialog to select multiple folders. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.
Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("failed to build tauri app")
.run(|_app, _event| {
FileDialogBuilder::new().pick_folders(|file_paths| {
// do something with the optional folder paths here
// the folder paths value is `None` if the user closed the dialog
})
})
sourcepub fn save_file<F: FnOnce(Option<PathBuf>) + Send + 'static>(self, f: F)
pub fn save_file<F: FnOnce(Option<PathBuf>) + Send + 'static>(self, f: F)
Shows the dialog to save a file.
This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.
Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("failed to build tauri app")
.run(|_app, _event| {
FileDialogBuilder::new().save_file(|file_path| {
// do something with the optional file path here
// the file path is `None` if the user closed the dialog
})
})
Trait Implementations
sourceimpl Debug for FileDialogBuilder
impl Debug for FileDialogBuilder
sourceimpl Default for FileDialogBuilder
impl Default for FileDialogBuilder
sourcefn default() -> FileDialogBuilder
fn default() -> FileDialogBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for FileDialogBuilder
impl Send for FileDialogBuilder
impl !Sync for FileDialogBuilder
impl Unpin for FileDialogBuilder
impl UnwindSafe for FileDialogBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more