From d9e451275224c3a0ef47034ea8b95052538bd6ad Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 13 Jul 2016 22:16:55 -0700 Subject: [PATCH] Fix linear layout focus switch --- src/view/linear_layout.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/view/linear_layout.rs b/src/view/linear_layout.rs index 25b488c..173a1ab 100644 --- a/src/view/linear_layout.rs +++ b/src/view/linear_layout.rs @@ -117,7 +117,8 @@ impl LinearLayout { .map(Child::as_mut) .position(View::take_focus) { - self.focus = i; + // We're looking at the list in reverse + self.focus -= i+1; EventResult::Consumed(None) } else { EventResult::Ignored @@ -130,7 +131,8 @@ impl LinearLayout { .rev() .map(Child::as_mut) .position(View::take_focus) { - self.focus = i; + // Our slice doesn't start at 0 + self.focus += i + 1; EventResult::Consumed(None) } else { EventResult::Ignored