Add SelectView::set_selection

This commit is contained in:
Alexandre Bury 2017-03-27 13:14:03 -07:00
parent 09202f55c8
commit 7c95114955

View File

@ -275,6 +275,13 @@ impl<T: 'static> SelectView<T> {
self.focus.get()
}
/// Moves the selection to the given position.
pub fn set_selection(&mut self, i: usize) {
// TODO: Check if `i > self.len()` ?
self.focus.set(i);
self.scrollbase.scroll_to(i);
}
fn focus_up(&mut self, n: usize) {
let focus = self.focus();
let n = min(focus, n);