diff --git a/src/views/list_view.rs b/src/views/list_view.rs index cf53921..e51a57c 100644 --- a/src/views/list_view.rs +++ b/src/views/list_view.rs @@ -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. diff --git a/src/views/select_view.rs b/src/views/select_view.rs index 99d70ed..29cbab1 100644 --- a/src/views/select_view.rs +++ b/src/views/select_view.rs @@ -190,6 +190,11 @@ impl SelectView { 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>(&mut self, label: S, value: T) { self.items.push(Item::new(label.into(), value));