Struct FileChooser
pub struct FileChooser { /* private fields */ }
dep_fltk
only.Expand description
FLTK’s own FileChooser
. Which differs for the Native FileDialog
Example:
use fltk::{prelude::*, *};
fn main() {
let app = app::App::default();
let mut win = window::Window::default().with_size(900, 300);
let mut chooser = dialog::FileChooser::new(
".", // directory
"*", // filter or pattern
dialog::FileChooserType::Multi, // chooser type
"Title Of Chooser", // title
);
chooser.show();
chooser.window().set_pos(300, 300);
// Block until user picks something.
// (The other way to do this is to use a callback())
//
while chooser.shown() {
app::wait();
}
// User hit cancel?
if chooser.value(1).is_none() {
println!("(User hit 'Cancel')");
return;
}
// Print what the user picked
println!("--------------------");
println!("DIRECTORY: '{}'", chooser.directory().unwrap());
println!(" VALUE: '{}'", chooser.value(1).unwrap()); // value starts at 1!
println!(" COUNT: {} files selected", chooser.count());
// Multiple files? Show all of them
if chooser.count() > 1 {
for t in 1..=chooser.count() {
println!(" VALUE[{}]: '{}'", t, chooser.value(t).unwrap());
}
}
win.end();
win.show();
app.run().unwrap();
}
Implementations§
§impl FileChooser
impl FileChooser
pub fn new<P>(
dir: P,
pattern: &str,
typ: FileChooserType,
title: &str,
) -> FileChooser
pub fn new<P>( dir: P, pattern: &str, typ: FileChooserType, title: &str, ) -> FileChooser
Instantiates a new FileChooser
pub unsafe fn delete(dlg: FileChooser)
pub unsafe fn delete(dlg: FileChooser)
Gets the new button of the FileChooser
Gets the preview button of the FileChooser
Gets the show hidden button of the FileChooser
pub fn set_callback<F>(&mut self, cb: F)where
F: FnMut(&mut FileChooser) + 'static,
pub fn set_callback<F>(&mut self, cb: F)where
F: FnMut(&mut FileChooser) + 'static,
Sets the callback of the FileChooser
pub fn set_directory<P>(&mut self, dir: P)
pub fn set_directory<P>(&mut self, dir: P)
Sets the directory of the FileChooser
pub fn set_filter(&mut self, pattern: &str)
pub fn set_filter(&mut self, pattern: &str)
Sets the filter for the dialog, can be: Multiple patterns can be used by separating them with tabs, like “.jpg\t.png\t*.gif\t*”. In addition, you can provide human-readable labels with the patterns inside parenthesis, like “JPEG Files (.jpg)\tPNG Files (.png)\tGIF Files (.gif)\tAll Files () And “Rust Files (*.{rs,txt,toml})”
pub fn filter_value(&self) -> i32
pub fn filter_value(&self) -> i32
Gets the current filename filter selection
pub fn set_filter_value(&mut self, f: i32)
pub fn set_filter_value(&mut self, f: i32)
Sets the filter value using an index to the ’\t’separated filters
pub fn hide(&mut self)
pub fn hide(&mut self)
Hides the file chooser
pub fn set_icon_size(&mut self, s: u8)
pub fn set_icon_size(&mut self, s: u8)
Sets the icon size of the FileChooser
pub fn set_ok_label(&mut self, l: &'static str)
pub fn set_ok_label(&mut self, l: &'static str)
Sets the label of the Ok button
pub fn set_preview(&mut self, e: bool)
pub fn set_preview(&mut self, e: bool)
Add preview to the FileChooser
pub fn rescan(&mut self)
pub fn rescan(&mut self)
Rescan the directory
pub fn rescan_keep_filename(&mut self)
pub fn rescan_keep_filename(&mut self)
Rescan the directory while keeping the file name
pub fn show(&mut self)
pub fn show(&mut self)
Shows the File Chooser
pub fn set_text_color(&mut self, c: Color)
pub fn set_text_color(&mut self, c: Color)
Sets the text color of the file chooser
pub fn text_color(&self) -> Color
pub fn text_color(&self) -> Color
Gets the text color of the file chooser
pub fn set_text_font(&mut self, f: Font)
pub fn set_text_font(&mut self, f: Font)
Sets the text font of the file chooser
pub fn set_text_size(&mut self, s: i32)
pub fn set_text_size(&mut self, s: i32)
Sets the text size of the file chooser
pub fn set_type(&mut self, t: FileChooserType)
pub fn set_type(&mut self, t: FileChooserType)
Sets the type of the FileChooser
pub fn get_type(&self) -> FileChooserType
pub fn get_type(&self) -> FileChooserType
Gets the type of the FileChooser
pub unsafe fn user_data(&self) -> Option<Box<dyn FnMut()>> ⓘ
pub unsafe fn user_data(&self) -> Option<Box<dyn FnMut()>> ⓘ
Gets the user data of the FileChooser
§Safety
Can invalidate the user data while the FileChooser
is in use
pub fn value(&mut self, f: i32) -> Option<String> ⓘ
pub fn value(&mut self, f: i32) -> Option<String> ⓘ
Gets the file or dir name chosen by the FileChooser
pub fn set_add_favorites_label(msg: &'static str)
pub fn set_add_favorites_label(msg: &'static str)
Set “Add favorites” label
pub fn set_all_files_label(msg: &'static str)
pub fn set_all_files_label(msg: &'static str)
Set “All Files” label
pub fn set_custom_filter_label(msg: &'static str)
pub fn set_custom_filter_label(msg: &'static str)
Set “Custom Filter” label
pub fn set_existing_file_label(msg: &'static str)
pub fn set_existing_file_label(msg: &'static str)
Set “Existing file” label
pub fn set_favorites_label(msg: &'static str)
pub fn set_favorites_label(msg: &'static str)
Set “Favorites” label
pub fn set_filename_label(msg: &'static str)
pub fn set_filename_label(msg: &'static str)
Set “Filename” label
pub fn set_filesystems_label(msg: &'static str)
pub fn set_filesystems_label(msg: &'static str)
Set “Filesystems” label
pub fn set_manage_favorites_label(msg: &'static str)
pub fn set_manage_favorites_label(msg: &'static str)
Set “Manage favorites” label
pub fn set_new_directory_label(msg: &'static str)
pub fn set_new_directory_label(msg: &'static str)
Set “New directory” label
pub fn set_new_directory_tooltip(msg: &'static str)
pub fn set_new_directory_tooltip(msg: &'static str)
Set “New directory” tooltip
pub fn set_preview_label(msg: &'static str)
pub fn set_preview_label(msg: &'static str)
Set “Preview” label
pub fn set_save_label(msg: &'static str)
pub fn set_save_label(msg: &'static str)
Set “Save” label
pub fn set_show_label(msg: &'static str)
pub fn set_show_label(msg: &'static str)
Set “Show” label
Set “hidden” label
pub fn set_position(&mut self, x: i32, y: i32)
pub fn set_position(&mut self, x: i32, y: i32)
Set the position of the file chooser
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileChooser
impl RefUnwindSafe for FileChooser
impl !Send for FileChooser
impl !Sync for FileChooser
impl Unpin for FileChooser
impl UnwindSafe for FileChooser
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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more