cursive/examples/list_view.rs
Alexandre Bury 1052c0b74c Remove EditView::min_length
Uses `.fixed_width()` from `Boxable` or something like that.
2016-08-03 21:58:00 -07:00

47 lines
1.6 KiB
Rust

extern crate cursive;
use cursive::prelude::*;
fn main() {
let mut siv = Cursive::new();
siv.add_layer(Dialog::empty()
.title("Please fill out this form")
.button("Ok", |s| s.quit())
.content(ListView::new()
.child("Name", EditView::new().fixed_width(10))
.child("Email",
LinearLayout::horizontal()
.child(EditView::new()
.disabled()
.with_id("email1")
.fixed_width(15))
.child(TextView::new("@"))
.child(EditView::new()
.disabled()
.with_id("email2")
.fixed_width(10)))
.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",
SelectView::new()
.popup()
.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());
}
})));
siv.run();
}