mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add focus switch to list_view example
This commit is contained in:
parent
d3669814b5
commit
5ac68b1ebf
@ -13,6 +13,17 @@ fn main() {
|
|||||||
.button("Ok", |s| s.quit())
|
.button("Ok", |s| s.quit())
|
||||||
.content(ListView::new()
|
.content(ListView::new()
|
||||||
.child("Name", EditView::new().fixed_width(10))
|
.child("Name", EditView::new().fixed_width(10))
|
||||||
|
.child("Receive spam?",
|
||||||
|
Checkbox::new()
|
||||||
|
.on_change(|s, checked| for name in &["email1",
|
||||||
|
"email2"] {
|
||||||
|
s.call_on_id(name, |view: &mut EditView| {
|
||||||
|
view.set_enabled(checked)
|
||||||
|
});
|
||||||
|
if checked {
|
||||||
|
s.focus_id("email1").unwrap();
|
||||||
|
}
|
||||||
|
}))
|
||||||
.child("Email",
|
.child("Email",
|
||||||
LinearLayout::horizontal()
|
LinearLayout::horizontal()
|
||||||
.child(EditView::new()
|
.child(EditView::new()
|
||||||
@ -24,14 +35,6 @@ fn main() {
|
|||||||
.disabled()
|
.disabled()
|
||||||
.with_id("email2")
|
.with_id("email2")
|
||||||
.fixed_width(10)))
|
.fixed_width(10)))
|
||||||
.child("Receive spam?",
|
|
||||||
Checkbox::new()
|
|
||||||
.on_change(|s, checked| for name in &["email1",
|
|
||||||
"email2"] {
|
|
||||||
s.call_on_id(name, |view: &mut EditView| {
|
|
||||||
view.set_enabled(checked)
|
|
||||||
});
|
|
||||||
}))
|
|
||||||
.delimiter()
|
.delimiter()
|
||||||
.child("Age",
|
.child("Age",
|
||||||
SelectView::new()
|
SelectView::new()
|
||||||
|
Loading…
Reference in New Issue
Block a user