2016-07-16 20:25:21 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
|
|
|
use cursive::Cursive;
|
|
|
|
use cursive::With;
|
2016-07-17 00:22:24 +00:00
|
|
|
use cursive::view::{ListView, Checkbox, Dialog, EditView, TextView, LinearLayout};
|
2016-07-16 20:25:21 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
|
|
|
siv.add_layer(Dialog::new(ListView::new()
|
|
|
|
.child("Name", EditView::new().min_length(10))
|
|
|
|
.child("Email", LinearLayout::horizontal()
|
2016-07-17 01:18:33 +00:00
|
|
|
.child(EditView::new().min_length(15).disabled().with_id("email1"))
|
2016-07-16 20:25:21 +00:00
|
|
|
.child(TextView::new("@"))
|
2016-07-17 01:18:33 +00:00
|
|
|
.child(EditView::new().min_length(10).disabled().with_id("email2")))
|
|
|
|
.child("Receive spam?", Checkbox::new().on_change(|s, checked| {
|
|
|
|
for name in &["email1", "email2"] {
|
|
|
|
let view: &mut EditView = s.find_id(name).unwrap();
|
|
|
|
view.set_enabled(checked);
|
|
|
|
}
|
|
|
|
}))
|
2016-07-16 20:25:21 +00:00
|
|
|
.delimiter()
|
|
|
|
.with(|list| {
|
|
|
|
for i in 0..50 {
|
|
|
|
list.add_child(&format!("Item {}", i), EditView::new());
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.title("Please fill out this form")
|
|
|
|
.button("Ok", |s| s.quit()));
|
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|