Add clear methods to SelectView and ListView

This commit is contained in:
Alexandre Bury 2016-09-05 15:33:52 -07:00
parent ce6975a8f7
commit 3701c85ffd
2 changed files with 10 additions and 0 deletions

View File

@ -64,6 +64,11 @@ impl ListView {
self.children.push(Child::Row(label.to_string(), Box::new(view)));
}
/// Removes all children from this view.
pub fn clear(&mut self) {
self.children.clear();
}
/// Adds a view to the end of the list.
///
/// Chainable variant.

View File

@ -190,6 +190,11 @@ impl<T: 'static> SelectView<T> {
self.items[self.focus()].value.clone()
}
/// Removes all items from this view.
pub fn clear(&mut self) {
self.items.clear();
}
/// Adds a item to the list, with given label and value.
pub fn add_item<S: Into<String>>(&mut self, label: S, value: T) {
self.items.push(Item::new(label.into(), value));