[][src]Struct cursive::views::SliderView

pub struct SliderView { /* fields omitted */ }

A horizontal or vertical slider.

Examples

use cursive::views::{Dialog, SliderView};

let slider_view = SliderView::horizontal(10)
    .on_change(|s, n| if n == 5 {
        s.add_layer(Dialog::info("5! Pick 5!"));
    })
    .on_enter(|s, n| match n {
        5 => s.add_layer(Dialog::info("You did it!")),
        n => s.add_layer(Dialog::info(format!("Why {}? Why not 5?", n))),
    });

Implementations

impl SliderView[src]

pub fn new(orientation: Orientation, max_value: usize) -> Self[src]

Creates a new SliderView in the given orientation.

The view will have a fixed length of max_value, with one tick per block.

The actual range of values for this slider is [0, max_value - 1].

pub fn vertical(max_value: usize) -> Self[src]

Creates a new vertical SliderView.

pub fn horizontal(max_value: usize) -> Self[src]

Creates a new horizontal SliderView.

pub fn set_value(&mut self, value: usize) -> EventResult[src]

Sets the current value.

Returns an event result with a possible callback, if on_change was set..

pub fn value(self, value: usize) -> Self[src]

Sets the current value.

Chainable variant.

pub fn get_value(&self) -> usize[src]

Gets the current value.

pub fn get_max_value(&self) -> usize[src]

Gets the max value.

pub fn on_change<F>(self, callback: F) -> Self where
    F: Fn(&mut Cursive, usize) + 'static, 
[src]

Sets a callback to be called when the slider is moved.

pub fn on_enter<F>(self, callback: F) -> Self where
    F: Fn(&mut Cursive, usize) + 'static, 
[src]

Sets a callback to be called when the key is pressed.

Trait Implementations

impl View for SliderView[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.