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::dummy();
siv.add_layer(Dialog::around(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.

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

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.

Returns None if the list is empty.

Removes all items from this view.

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

Gets an item at given idx or None.

use cursive::Cursive;
use cursive::views::{SelectView, TextView};
let select = SelectView::new()
    .item("Short", 1);
assert_eq!(select.get_item(0), Some(("Short", &1)));

Gets a mut item at given idx or None.

Removes an item from the list.

Returns a callback in response to the selection change.

You should run this callback with a &mut Cursive.

Inserts an item at position index, shifting all elements after it to the right.

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.

Returns true if this list has no item.

Moves the selection to the given position.

Returns a callback in response to the selection change.

You should run this callback with a &mut Cursive.

Sets the selection to the given position.

Chainable variant.

Does not apply on_select callbacks.

Moves the selection up by the given number of rows.

Returns a callback in response to the selection change.

You should run this callback with a &mut Cursive:

fn select_up(siv: &mut Cursive, view: &mut SelectView<()>) {
    let cb = view.select_up(1);
    cb(siv);
}

Moves the selection down by the given number of rows.

Returns a callback in response to the selection change.

You should run this callback with a &mut Cursive.

impl SelectView<String>
[src]

Convenient method to use the label as value.

Chainable variant of add_item_str

Convenient method to use the label as value.

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> Default for SelectView<T>
[src]

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

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

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

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

Called when an event is received (key press, mouse event, ...). Read more

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

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

What part of the view is important and should be visible? Read more

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

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

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

Auto Trait Implementations

impl<T = String> !Send for SelectView<T>

impl<T = String> !Sync for SelectView<T>