diff --git a/src/views/linear_layout.rs b/src/views/linear_layout.rs index f1bbd6d..219705d 100644 --- a/src/views/linear_layout.rs +++ b/src/views/linear_layout.rs @@ -279,11 +279,11 @@ impl LinearLayout { // this will give us the allowed window for a click. let child_size = item.child.size.get(self.orientation); - if (item.offset + child_size > position) - && item.child.view.take_focus(direction::Direction::none()) - { - // eprintln!("It's a match!"); - self.focus = i; + if item.offset + child_size > position { + if item.child.view.take_focus(direction::Direction::none()) + { + self.focus = i; + } return; } } diff --git a/src/views/scroll_view.rs b/src/views/scroll_view.rs index 43e4fc9..2dcc4fb 100644 --- a/src/views/scroll_view.rs +++ b/src/views/scroll_view.rs @@ -7,6 +7,8 @@ use xy::XY; use Printer; use With; +use std::cmp::min; + /// Wraps a view in a scrollable area. pub struct ScrollView { inner_size: Vec2, @@ -190,7 +192,7 @@ where EventResult::Consumed(None) } Event::Mouse { event: MouseEvent::WheelDown, .. } if self.enabled.y && (self.offset.y + self.last_size.y < self.inner_size.y) => { - self.offset.y += 3; + self.offset.y = min(self.inner_size.y.saturating_sub(self.last_size.y), self.offset.y + 3); EventResult::Consumed(None) } Event::Ctrl(Key::Up) |