pub struct FolderDialog<'a> {
pub title: &'a str,
pub directory: Option<&'a Path>,
pub owner: Option<&'a dyn HasWindowHandle>,
}Expand description
Folder dialog.
The folder dialog allows the user to select a folder or directory.
use std::env;
let folder = rustydialogs::FolderDialog {
title: "Select Folder",
directory: env::current_dir().ok().as_deref(),
owner: None,
}.show();
if let Some(path) = folder {
println!("Picked folder: {}", path.display());
}Fields§
§title: &'a strThe title of the dialog.
directory: Option<&'a Path>The initial directory to show in the folder dialog.
owner: Option<&'a dyn HasWindowHandle>The owner window of the dialog.
Implementations§
Source§impl<'a> FolderDialog<'a>
impl<'a> FolderDialog<'a>
Sourcepub fn show(&self) -> Option<PathBuf>
pub fn show(&self) -> Option<PathBuf>
Show the dialog.
Examples found in repository?
examples/folder_dialog.rs (line 10)
1fn main() {
2 let current_dir = std::env::current_dir().ok();
3
4 let dialog = rustydialogs::FolderDialog {
5 title: "Select a folder",
6 directory: current_dir.as_deref(),
7 owner: None,
8 };
9
10 match dialog.show() {
11 Some(path) => println!("Selected folder: {}", path.display()),
12 None => println!("Folder selection canceled"),
13 }
14}More examples
examples/tests.rs (line 271)
262fn test_folder_dialog() {
263 println!("\n{}", Color("==== Testing FolderDialog ====", "120;190;255"));
264
265 step("Select the `src` folder and press Open.",
266 Some(env::current_dir().unwrap().join("src")),
267 || rustydialogs::FolderDialog {
268 title: "[tests] FolderDialog",
269 directory: None,
270 owner: None,
271 }.show()
272 );
273
274 step("Dismiss the dialog.",
275 None,
276 || rustydialogs::FolderDialog {
277 title: "[tests] Dismiss FolderDialog",
278 directory: None,
279 owner: None,
280 }.show()
281 );
282}Trait Implementations§
Source§impl<'a> Clone for FolderDialog<'a>
impl<'a> Clone for FolderDialog<'a>
Source§fn clone(&self) -> FolderDialog<'a>
fn clone(&self) -> FolderDialog<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for FolderDialog<'a>
Auto Trait Implementations§
impl<'a> Freeze for FolderDialog<'a>
impl<'a> !RefUnwindSafe for FolderDialog<'a>
impl<'a> !Send for FolderDialog<'a>
impl<'a> !Sync for FolderDialog<'a>
impl<'a> Unpin for FolderDialog<'a>
impl<'a> UnsafeUnpin for FolderDialog<'a>
impl<'a> !UnwindSafe for FolderDialog<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more