From 5ac68b1ebf38355d057b78218e508e486794ff50 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Tue, 28 Mar 2017 19:00:46 -0700 Subject: [PATCH] Add focus switch to list_view example --- examples/list_view.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/list_view.rs b/examples/list_view.rs index a8f74b7..cd59e48 100644 --- a/examples/list_view.rs +++ b/examples/list_view.rs @@ -13,6 +13,17 @@ fn main() { .button("Ok", |s| s.quit()) .content(ListView::new() .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", LinearLayout::horizontal() .child(EditView::new() @@ -24,14 +35,6 @@ fn main() { .disabled() .with_id("email2") .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() .child("Age", SelectView::new()