Struct cursive::views::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.

Examples

let mut time_select = SelectView::new().h_align(HAlign::Center);
time_select.add_item("Short", 1);
time_select.add_item("Medium", 5);
time_select.add_item("Long", 10);

time_select.set_on_submit(|s, time| {
    s.pop_layer();
    let text = format!("You will wait for {} minutes...", time);
    s.add_layer(Dialog::new(TextView::new(text))
                    .button("Quit", |s| s.quit()));
});

let mut siv = Cursive::new();
siv.add_layer(Dialog::new(time_select)
                .title("How long is your wait?"));

Methods

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

Creates a new empty SelectView.

Turns self into a popup select view.

Chainable variant.

Turns self into a popup select view.

Disables this view.

A disabled view cannot be selected.

Disables this view.

Chainable variant.

Re-enables this view.

Enable or disable this view.

Returns true if this view is enabled.

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

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

Chainable variant.

Sets a callback to be used when <Enter> is pressed.

The item currently selected will be given to the callback.

Sets a callback to be used when <Enter> is pressed.

The item currently selected will be given to the callback.

Chainable variant.

Sets the alignment for this view.

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

Sets the horizontal alignment for this view.

Returns the value of the currently selected item.

Panics if the list is empty.

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

Removes an item from the list.

Chainable variant of add_item

Adds all items from from an iterator.

Adds all items from from an iterator.

Chainable variant.

Returns the id of the item currently selected.

Returns None if the list is empty.

Returns the number of items in this list.

impl SelectView<String>
[src]

Convenient method to use the label as value.

Chainable variant of add_item_str

Adds all strings from an iterator.

Examples

let mut select_view = SelectView::new();
select_view.add_all_str(vec!["a", "b", "c"]);

Adds all strings from an iterator.

Chainable variant.

Trait Implementations

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

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

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

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

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

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

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

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