2016-07-16 20:25:21 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2016-07-21 04:25:14 +00:00
|
|
|
use cursive::prelude::*;
|
2016-07-16 20:25:21 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
2016-07-26 03:43:01 +00:00
|
|
|
siv.add_layer(Dialog::empty()
|
|
|
|
.title("Please fill out this form")
|
|
|
|
.button("Ok", |s| s.quit())
|
|
|
|
.content(ListView::new()
|
2016-07-20 07:30:00 +00:00
|
|
|
.child("Name", EditView::new().min_length(10))
|
|
|
|
.child("Email",
|
|
|
|
LinearLayout::horizontal()
|
|
|
|
.child(EditView::new()
|
|
|
|
.min_length(15)
|
|
|
|
.disabled()
|
|
|
|
.with_id("email1"))
|
|
|
|
.child(TextView::new("@"))
|
|
|
|
.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);
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.delimiter()
|
|
|
|
.child("Age",
|
2016-07-26 03:43:01 +00:00
|
|
|
SelectView::new()
|
|
|
|
.popup()
|
2016-07-20 07:30:00 +00:00
|
|
|
.item_str("0-18")
|
|
|
|
.item_str("19-30")
|
|
|
|
.item_str("31-40")
|
|
|
|
.item_str("41+"))
|
|
|
|
.with(|list| {
|
|
|
|
for i in 0..50 {
|
|
|
|
list.add_child(&format!("Item {}", i), EditView::new());
|
|
|
|
}
|
2016-07-26 03:43:01 +00:00
|
|
|
})));
|
2016-07-16 20:25:21 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|