pub struct Input { /* private fields */ }
Expand description
A dialog box with a text input field.
This dialog box displays a text and an input field. It returns the text entered by the user or
None
if the user cancelled the dialog.
§Example
use dialog::DialogBox;
let name = dialog::Input::new("Please enter your name")
.title("Name")
.show()
.expect("Could not display dialog box");
match name {
Some(name) => println!("Hello {}!", name),
None => println!("Hello stranger!"),
};
Implementations§
Source§impl Input
impl Input
Sourcepub fn new(text: impl Into<String>) -> Input
pub fn new(text: impl Into<String>) -> Input
Creates a new input dialog box with the given text.
Examples found in repository?
examples/input.rs (line 7)
6fn main() -> dialog::Result<()> {
7 let input1 = dialog::Input::new("Please enter something").show()?;
8 let input2 = dialog::Input::new("Please enter something")
9 .title("Input form")
10 .show()?;
11 let input3 = dialog::Input::new("Please enter something with a default")
12 .title("Input form")
13 .default("input")
14 .show()?;
15
16 println!("Input 1: {:?}", input1);
17 println!("Input 2: {:?}", input2);
18 println!("Input 3: {:?}", input3);
19 Ok(())
20}
Sourcepub fn title(&mut self, title: impl Into<String>) -> &mut Input
pub fn title(&mut self, title: impl Into<String>) -> &mut Input
Sets the title of this input box.
This method returns a reference to self
to enable chaining.
Examples found in repository?
examples/input.rs (line 9)
6fn main() -> dialog::Result<()> {
7 let input1 = dialog::Input::new("Please enter something").show()?;
8 let input2 = dialog::Input::new("Please enter something")
9 .title("Input form")
10 .show()?;
11 let input3 = dialog::Input::new("Please enter something with a default")
12 .title("Input form")
13 .default("input")
14 .show()?;
15
16 println!("Input 1: {:?}", input1);
17 println!("Input 2: {:?}", input2);
18 println!("Input 3: {:?}", input3);
19 Ok(())
20}
Sourcepub fn default(&mut self, default: impl Into<String>) -> &mut Input
pub fn default(&mut self, default: impl Into<String>) -> &mut Input
Sets the default value of this input box.
This method returns a reference to self
to enable chaining.
Examples found in repository?
examples/input.rs (line 13)
6fn main() -> dialog::Result<()> {
7 let input1 = dialog::Input::new("Please enter something").show()?;
8 let input2 = dialog::Input::new("Please enter something")
9 .title("Input form")
10 .show()?;
11 let input3 = dialog::Input::new("Please enter something with a default")
12 .title("Input form")
13 .default("input")
14 .show()?;
15
16 println!("Input 1: {:?}", input1);
17 println!("Input 2: {:?}", input2);
18 println!("Input 3: {:?}", input3);
19 Ok(())
20}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
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