mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +00:00
Add clear
methods to SelectView
and ListView
This commit is contained in:
parent
ce6975a8f7
commit
3701c85ffd
@ -64,6 +64,11 @@ impl ListView {
|
|||||||
self.children.push(Child::Row(label.to_string(), Box::new(view)));
|
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.
|
/// Adds a view to the end of the list.
|
||||||
///
|
///
|
||||||
/// Chainable variant.
|
/// Chainable variant.
|
||||||
|
@ -190,6 +190,11 @@ impl<T: 'static> SelectView<T> {
|
|||||||
self.items[self.focus()].value.clone()
|
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.
|
/// Adds a item to the list, with given label and value.
|
||||||
pub fn add_item<S: Into<String>>(&mut self, label: S, value: T) {
|
pub fn add_item<S: Into<String>>(&mut self, label: S, value: T) {
|
||||||
self.items.push(Item::new(label.into(), value));
|
self.items.push(Item::new(label.into(), value));
|
||||||
|
Loading…
Reference in New Issue
Block a user