Fix linearlayout focus grab

This commit is contained in:
Alexandre Bury 2018-05-21 18:08:41 -07:00
parent 3bc07661d0
commit 2db49da1fe
2 changed files with 8 additions and 6 deletions

View File

@ -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())
if item.offset + child_size > position {
if item.child.view.take_focus(direction::Direction::none())
{
// eprintln!("It's a match!");
self.focus = i;
}
return;
}
}

View File

@ -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<V> {
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) |