Struct cursive_core::views::ListView
source · pub struct ListView { /* private fields */ }
Expand description
Displays a list of elements.
Implementations§
source§impl ListView
impl ListView
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this view contains no children.
Returns false
if at least a delimiter or a view is present.
sourcepub fn get_row(&self, id: usize) -> &ListChild
pub fn get_row(&self, id: usize) -> &ListChild
Returns a reference to the child at the given position.
sourcepub fn add_child<V: IntoBoxedView + 'static>(&mut self, label: &str, view: V)
pub fn add_child<V: IntoBoxedView + 'static>(&mut self, label: &str, view: V)
Adds a view to the end of the list.
sourcepub fn child<V: IntoBoxedView + 'static>(self, label: &str, view: V) -> Self
pub fn child<V: IntoBoxedView + 'static>(self, label: &str, view: V) -> Self
Adds a view to the end of the list.
Chainable variant.
sourcepub fn add_delimiter(&mut self)
pub fn add_delimiter(&mut self)
Adds a delimiter to the end of the list.
sourcepub fn remove_child(&mut self, index: usize) -> ListChild
pub fn remove_child(&mut self, index: usize) -> ListChild
sourcepub fn set_on_select<F>(&mut self, cb: F)where
F: Fn(&mut Cursive, &String) + 'static,
pub fn set_on_select<F>(&mut self, cb: F)where
F: Fn(&mut Cursive, &String) + 'static,
Sets a callback to be used when an item is selected.
Trait Implementations§
source§impl View for ListView
impl View for ListView
source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Draws the view with the given printer (includes bounds) and focus. Read more
source§fn required_size(&mut self, req: Vec2) -> Vec2
fn required_size(&mut self, req: Vec2) -> Vec2
Returns the minimum size the view requires with the given restrictions. Read more
source§fn layout(&mut self, size: Vec2)
fn layout(&mut self, size: Vec2)
Called once the size for this view has been decided. Read more
source§fn on_event(&mut self, event: Event) -> EventResult
fn on_event(&mut self, event: Event) -> EventResult
Called when an event is received (key press, mouse event, …). Read more
source§fn take_focus(&mut self, source: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, source: Direction) -> Result<EventResult, CannotFocus>
Attempt to give this view the focus. Read more
source§fn call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
fn call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
Runs a closure on the view identified by the given selector. Read more
source§fn focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<EventResult, ViewNotFound>
fn focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<EventResult, ViewNotFound>
Moves the focus to the view identified by the given selector. Read more
source§fn important_area(&self, size: Vec2) -> Rect
fn important_area(&self, size: Vec2) -> Rect
What part of the view is important and should be visible? Read more