pub struct NativeFileChooser { /* private fields */ }
Expand description
FLTK’s NativeFileChooser
Implementations§
Source§impl NativeFileChooser
impl NativeFileChooser
Sourcepub fn new(op: NativeFileChooserType) -> NativeFileChooser
pub fn new(op: NativeFileChooserType) -> NativeFileChooser
Creates an new file dialog
Examples found in repository?
examples/editor.rs (line 84)
83fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
84 let mut nfc = dialog::NativeFileChooser::new(mode);
85 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
86 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
87 } else if mode == dialog::NativeFileChooserType::BrowseFile {
88 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
89 nfc.set_filter("*.{txt,rs,toml}");
90 }
91 match nfc.show() {
92 Err(e) => {
93 eprintln!("{}", e);
94 None
95 }
96 Ok(a) => match a {
97 dialog::NativeFileChooserAction::Success => {
98 let name = nfc.filename();
99 if name.as_os_str().is_empty() {
100 dialog::alert("Please specify a file!");
101 None
102 } else {
103 Some(name)
104 }
105 }
106 dialog::NativeFileChooserAction::Cancelled => None,
107 },
108 }
109}
More examples
examples/editor2.rs (line 31)
30fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
31 let mut nfc = dialog::NativeFileChooser::new(mode);
32 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
33 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
34 } else if mode == dialog::NativeFileChooserType::BrowseFile {
35 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
36 nfc.set_filter("*.{txt,rs,toml}");
37 }
38 match nfc.show() {
39 Err(e) => {
40 eprintln!("{}", e);
41 None
42 }
43 Ok(a) => match a {
44 dialog::NativeFileChooserAction::Success => {
45 let name = nfc.filename();
46 if name.as_os_str().is_empty() {
47 dialog::alert("Please specify a file!");
48 None
49 } else {
50 Some(name)
51 }
52 }
53 dialog::NativeFileChooserAction::Cancelled => None,
54 },
55 }
56}
Sourcepub fn filename(&self) -> PathBuf
pub fn filename(&self) -> PathBuf
Returns the chosen file name
Examples found in repository?
examples/editor.rs (line 98)
83fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
84 let mut nfc = dialog::NativeFileChooser::new(mode);
85 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
86 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
87 } else if mode == dialog::NativeFileChooserType::BrowseFile {
88 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
89 nfc.set_filter("*.{txt,rs,toml}");
90 }
91 match nfc.show() {
92 Err(e) => {
93 eprintln!("{}", e);
94 None
95 }
96 Ok(a) => match a {
97 dialog::NativeFileChooserAction::Success => {
98 let name = nfc.filename();
99 if name.as_os_str().is_empty() {
100 dialog::alert("Please specify a file!");
101 None
102 } else {
103 Some(name)
104 }
105 }
106 dialog::NativeFileChooserAction::Cancelled => None,
107 },
108 }
109}
More examples
examples/editor2.rs (line 45)
30fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
31 let mut nfc = dialog::NativeFileChooser::new(mode);
32 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
33 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
34 } else if mode == dialog::NativeFileChooserType::BrowseFile {
35 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
36 nfc.set_filter("*.{txt,rs,toml}");
37 }
38 match nfc.show() {
39 Err(e) => {
40 eprintln!("{}", e);
41 None
42 }
43 Ok(a) => match a {
44 dialog::NativeFileChooserAction::Success => {
45 let name = nfc.filename();
46 if name.as_os_str().is_empty() {
47 dialog::alert("Please specify a file!");
48 None
49 } else {
50 Some(name)
51 }
52 }
53 dialog::NativeFileChooserAction::Cancelled => None,
54 },
55 }
56}
Sourcepub fn show(&mut self) -> Result<NativeFileChooserAction, FltkError>
pub fn show(&mut self) -> Result<NativeFileChooserAction, FltkError>
Shows the file dialog
Examples found in repository?
examples/editor.rs (line 91)
83fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
84 let mut nfc = dialog::NativeFileChooser::new(mode);
85 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
86 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
87 } else if mode == dialog::NativeFileChooserType::BrowseFile {
88 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
89 nfc.set_filter("*.{txt,rs,toml}");
90 }
91 match nfc.show() {
92 Err(e) => {
93 eprintln!("{}", e);
94 None
95 }
96 Ok(a) => match a {
97 dialog::NativeFileChooserAction::Success => {
98 let name = nfc.filename();
99 if name.as_os_str().is_empty() {
100 dialog::alert("Please specify a file!");
101 None
102 } else {
103 Some(name)
104 }
105 }
106 dialog::NativeFileChooserAction::Cancelled => None,
107 },
108 }
109}
More examples
examples/editor2.rs (line 38)
30fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
31 let mut nfc = dialog::NativeFileChooser::new(mode);
32 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
33 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
34 } else if mode == dialog::NativeFileChooserType::BrowseFile {
35 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
36 nfc.set_filter("*.{txt,rs,toml}");
37 }
38 match nfc.show() {
39 Err(e) => {
40 eprintln!("{}", e);
41 None
42 }
43 Ok(a) => match a {
44 dialog::NativeFileChooserAction::Success => {
45 let name = nfc.filename();
46 if name.as_os_str().is_empty() {
47 dialog::alert("Please specify a file!");
48 None
49 } else {
50 Some(name)
51 }
52 }
53 dialog::NativeFileChooserAction::Cancelled => None,
54 },
55 }
56}
Sourcepub fn set_option(&mut self, opt: NativeFileChooserOptions)
pub fn set_option(&mut self, opt: NativeFileChooserOptions)
Sets the option for the dialog
Examples found in repository?
examples/editor.rs (line 86)
83fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
84 let mut nfc = dialog::NativeFileChooser::new(mode);
85 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
86 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
87 } else if mode == dialog::NativeFileChooserType::BrowseFile {
88 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
89 nfc.set_filter("*.{txt,rs,toml}");
90 }
91 match nfc.show() {
92 Err(e) => {
93 eprintln!("{}", e);
94 None
95 }
96 Ok(a) => match a {
97 dialog::NativeFileChooserAction::Success => {
98 let name = nfc.filename();
99 if name.as_os_str().is_empty() {
100 dialog::alert("Please specify a file!");
101 None
102 } else {
103 Some(name)
104 }
105 }
106 dialog::NativeFileChooserAction::Cancelled => None,
107 },
108 }
109}
More examples
examples/editor2.rs (line 33)
30fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
31 let mut nfc = dialog::NativeFileChooser::new(mode);
32 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
33 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
34 } else if mode == dialog::NativeFileChooserType::BrowseFile {
35 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
36 nfc.set_filter("*.{txt,rs,toml}");
37 }
38 match nfc.show() {
39 Err(e) => {
40 eprintln!("{}", e);
41 None
42 }
43 Ok(a) => match a {
44 dialog::NativeFileChooserAction::Success => {
45 let name = nfc.filename();
46 if name.as_os_str().is_empty() {
47 dialog::alert("Please specify a file!");
48 None
49 } else {
50 Some(name)
51 }
52 }
53 dialog::NativeFileChooserAction::Cancelled => None,
54 },
55 }
56}
Sourcepub fn set_type(&mut self, op: NativeFileChooserType)
pub fn set_type(&mut self, op: NativeFileChooserType)
Sets the type for the dialog
Sourcepub fn set_filter(&mut self, f: &str)
pub fn set_filter(&mut self, f: &str)
Sets the filter for the dialog, can be:
A single wildcard (e.g. "*.txt"
).
Multiple wildcards (e.g. "*.{cxx,h,H}"
).
A descriptive name followed by a \t
and a wildcard (e.g. "Text Files\t*.txt"
).
A list of separate wildcards with a \n
between each (e.g. "*.{cxx,H}\n*.txt"
).
A list of descriptive names and wildcards (e.g. "C++ Files\t*.{cxx,H}\nTxt Files\t*.txt"
)
Examples found in repository?
examples/editor.rs (line 89)
83fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
84 let mut nfc = dialog::NativeFileChooser::new(mode);
85 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
86 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
87 } else if mode == dialog::NativeFileChooserType::BrowseFile {
88 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
89 nfc.set_filter("*.{txt,rs,toml}");
90 }
91 match nfc.show() {
92 Err(e) => {
93 eprintln!("{}", e);
94 None
95 }
96 Ok(a) => match a {
97 dialog::NativeFileChooserAction::Success => {
98 let name = nfc.filename();
99 if name.as_os_str().is_empty() {
100 dialog::alert("Please specify a file!");
101 None
102 } else {
103 Some(name)
104 }
105 }
106 dialog::NativeFileChooserAction::Cancelled => None,
107 },
108 }
109}
More examples
examples/editor2.rs (line 36)
30fn nfc_get_file(mode: dialog::NativeFileChooserType) -> Option<PathBuf> {
31 let mut nfc = dialog::NativeFileChooser::new(mode);
32 if mode == dialog::NativeFileChooserType::BrowseSaveFile {
33 nfc.set_option(dialog::NativeFileChooserOptions::SaveAsConfirm);
34 } else if mode == dialog::NativeFileChooserType::BrowseFile {
35 nfc.set_option(dialog::NativeFileChooserOptions::NoOptions);
36 nfc.set_filter("*.{txt,rs,toml}");
37 }
38 match nfc.show() {
39 Err(e) => {
40 eprintln!("{}", e);
41 None
42 }
43 Ok(a) => match a {
44 dialog::NativeFileChooserAction::Success => {
45 let name = nfc.filename();
46 if name.as_os_str().is_empty() {
47 dialog::alert("Please specify a file!");
48 None
49 } else {
50 Some(name)
51 }
52 }
53 dialog::NativeFileChooserAction::Cancelled => None,
54 },
55 }
56}
Sourcepub fn filter_value(&self) -> i32
pub fn filter_value(&self) -> i32
Gets the current filename filter selection
Sourcepub 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
Sourcepub fn set_preset_file(&mut self, f: &str)
pub fn set_preset_file(&mut self, f: &str)
Sets the default filename for the dialog
Sourcepub fn error_message(&self) -> Option<String>
pub fn error_message(&self) -> Option<String>
returns the error message from the file dialog
Trait Implementations§
Source§impl Debug for NativeFileChooser
impl Debug for NativeFileChooser
Auto Trait Implementations§
impl Freeze for NativeFileChooser
impl RefUnwindSafe for NativeFileChooser
impl !Send for NativeFileChooser
impl !Sync for NativeFileChooser
impl Unpin for NativeFileChooser
impl UnwindSafe for NativeFileChooser
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