mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-10 03:10:41 +00:00
Update EditView
doc
With updated `examples/edit.rs` content
This commit is contained in:
parent
3410150ed5
commit
ede5c616f6
@ -34,5 +34,4 @@ fn show_popup(s: &mut Cursive, name: &str) {
|
|||||||
s.add_layer(Dialog::new(TextView::new(content))
|
s.add_layer(Dialog::new(TextView::new(content))
|
||||||
.button("Quit", |s| s.quit()));
|
.button("Quit", |s| s.quit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,26 +27,33 @@ use utils::simple_suffix_length;
|
|||||||
/// let mut siv = Cursive::new();
|
/// let mut siv = Cursive::new();
|
||||||
///
|
///
|
||||||
/// // Create a dialog with an edit text and a button.
|
/// // Create a dialog with an edit text and a button.
|
||||||
/// siv.add_layer(Dialog::new(EditView::new().min_length(20).with_id("edit"))
|
/// // The user can either hit the <Ok> button,
|
||||||
/// .padding((1, 1, 1, 0))
|
/// // or press Enter on the edit text.
|
||||||
/// .title("Enter your name")
|
/// siv.add_layer(Dialog::empty()
|
||||||
/// .button("Ok", |s| {
|
/// .title("Enter your name")
|
||||||
/// // When the button is clicked,
|
/// .padding((1, 1, 1, 0))
|
||||||
/// // read the text and print it in a new dialog.
|
/// .content(EditView::new()
|
||||||
/// let name = s.find_id::<EditView>("edit")
|
/// .min_length(20)
|
||||||
/// .unwrap()
|
/// .on_submit(show_popup)
|
||||||
/// .get_content()
|
/// .with_id("name"))
|
||||||
/// .to_string();
|
/// .button("Ok", |s| {
|
||||||
/// if name.is_empty() {
|
/// let name = s.find_id::<EditView>("name")
|
||||||
/// s.add_layer(Dialog::new(TextView::new("Please enter a name!"))
|
/// .unwrap()
|
||||||
/// .dismiss_button("Ok"));
|
/// .get_content();
|
||||||
/// } else {
|
/// show_popup(s, &name);
|
||||||
/// let content = format!("Hello {}!", name);
|
/// }));
|
||||||
/// s.pop_layer();
|
///
|
||||||
/// s.add_layer(Dialog::new(TextView::new(content))
|
/// fn show_popup(s: &mut Cursive, name: &str) {
|
||||||
/// .button("Quit", |s| s.quit()));
|
/// if name.is_empty() {
|
||||||
/// }
|
/// s.add_layer(Dialog::info("Please enter a name!"));
|
||||||
/// }));
|
/// } else {
|
||||||
|
/// let content = format!("Hello {}!", name);
|
||||||
|
/// s.pop_layer();
|
||||||
|
/// s.add_layer(Dialog::new(TextView::new(content))
|
||||||
|
/// .button("Quit", |s| s.quit()));
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct EditView {
|
pub struct EditView {
|
||||||
|
Loading…
Reference in New Issue
Block a user