Skip to content

Commit

Permalink
Add clear methods to SelectView and ListView
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Sep 5, 2016
1 parent ce6975a commit 3701c85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/views/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/views/select_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 3701c85

Please sign in to comment.