Struct cursive::views::SelectView [] [src]

pub struct SelectView<T = String> { /* 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::around(TextView::new(text))
                    .button("Quit", |s| s.quit()));
});

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

Methods

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

[src]

Creates a new empty SelectView.

[src]

Turns self into a popup select view.

Chainable variant.

[src]

Turns self into a popup select view.

[src]

Disables this view.

A disabled view cannot be selected.

[src]

Disables this view.

Chainable variant.

[src]

Re-enables this view.

[src]

Enable or disable this view.

[src]

Returns true if this view is enabled.

[src]

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

[src]

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

Chainable variant.

[src]

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

The item currently selected will be given to the callback.

Here, V can be T itself, or a type that can be borrowed from T.

[src]

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

The item currently selected will be given to the callback.

Chainable variant.

[src]

Sets the alignment for this view.

[src]

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

[src]

Sets the horizontal alignment for this view.

[src]

Returns the value of the currently selected item.

Panics if the list is empty.

[src]

Removes all items from this view.

[src]

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

[src]

Removes an item from the list.

[src]

Chainable variant of add_item

[src]

Adds all items from from an iterator.

[src]

Adds all items from from an iterator.

Chainable variant.

[src]

Returns the id of the item currently selected.

Returns None if the list is empty.

[src]

Returns the number of items in this list.

[src]

Returns true if this list has no item.

[src]

Moves the selection to the given position.

[src]

Moves the selection up by the given number of rows.

[src]

Moves the selection down by the given number of rows.

impl SelectView<String>
[src]

[src]

Convenient method to use the label as value.

[src]

Chainable variant of add_item_str

[src]

Adds all strings from an iterator.

Examples

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

[src]

Adds all strings from an iterator.

Chainable variant.

Trait Implementations

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

[src]

Returns the "default value" for a type. Read more

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

[src]

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

[src]

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

[src]

Called when a key was pressed. Read more

[src]

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

[src]

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

[src]

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

[src]

Runs a closure on the view identified by the given selector. Read more

[src]

Moves the focus to the view identified by the given selector. Read more