Struct cursive::prelude::SelectView [] [src]

pub struct SelectView<T = String> {
    // some fields omitted
}

View to select an item among a list.

It contains a list of values of type T, with associated labels.

Methods

impl<T: 'static> SelectView<T>
[src]

fn new() -> Self

Creates a new empty SelectView.

fn popup(self) -> Self

Turns self into a popup select view.

Chainable variant.

fn set_popup(&mut self, popup: bool)

Turns self into a popup select view.

fn disable(&mut self)

Disables this view.

A disabled view cannot be selected.

fn disabled(self) -> Self

Disables this view.

Chainable variant.

fn enable(&mut self)

Re-enables this view.

fn set_enabled(&mut self, enabled: bool)

Enable or disable this view.

fn is_enabled(&self) -> bool

Returns true if this view is enabled.

fn set_on_select<F>(&mut self, cb: F) where F: Fn(&mut Cursive, &T) + 'static

Sets a callback to be used when an item is selected.

(When ENTER is pressed on an item).

fn on_select<F>(self, cb: F) -> Self where F: Fn(&mut Cursive, &T) + 'static

Sets a callback to be used when an item is selected.

(When ENTER is pressed on an item).

Chainable variant.

fn align(self, align: Align) -> Self

Sets the alignment for this view.

fn v_align(self, v: VAlign) -> Self

Sets the vertical alignment for this view. (If the view is given too much space vertically.)

fn h_align(self, h: HAlign) -> Self

Sets the horizontal alignment for this view.

fn selection(&self) -> Rc<T>

Returns the value of the currently selected item.

Panics if the list is empty.

fn add_item(&mut self, label: &str, value: T)

Adds a item to the list, with given label and value.

fn item(self, label: &str, value: T) -> Self

Chainable variant of add_item

fn with_id(self, label: &str) -> IdView<Self>

Wraps this view into an IdView with the given id.

impl SelectView<String>
[src]

fn add_item_str(&mut self, label: &str)

Convenient method to use the label as value.

fn item_str(self, label: &str) -> Self

Chainable variant of add_item_str

Trait Implementations

impl<T: 'static> View for SelectView<T>
[src]

fn draw(&self, printer: &Printer)

Draws the view with the given printer (includes bounds) and focus.

fn get_min_size(&mut self, req: Vec2) -> Vec2

Returns the minimum size the view requires with the given restrictions. Read more

fn on_event(&mut self, event: Event) -> EventResult

Called when a key was pressed. Default implementation just ignores it.

fn take_focus(&mut self, _: Direction) -> bool

This view is offered focus. Will it take it? Read more

fn layout(&mut self, size: Vec2)

Called once the size for this view has been decided, Read more

fn needs_relayout(&self) -> bool

Returns true if the view content changed since last layout phase. Read more

fn find(&mut self, &Selector) -> Option<&mut Any>

Finds the view pointed to by the given path. Read more