[][src]Struct cursive::views::EnableableView

pub struct EnableableView<V> { /* fields omitted */ }

Wrapper around another view that can be enabled/disabled at will.

When disabled, all child views will be disabled and will stop receiving events.

Examples

use cursive_core::Cursive;
use cursive_core::views::{Button, EnableableView, Checkbox, LinearLayout};
use cursive_core::traits::Identifiable;

let mut siv = Cursive::dummy();

siv.add_layer(LinearLayout::vertical()
    .child(EnableableView::new(Checkbox::new()).with_name("my_view"))
    .child(Button::new("Toggle", |s| {
        s.call_on_name("my_view", |v: &mut EnableableView<Checkbox>| {
            // This will disable (or re-enable) the checkbox, preventing the user from
            // interacting with it.
            v.set_enabled(!v.is_enabled());
        });
    }))
);

Implementations

impl<V> EnableableView<V>[src]

pub fn new(view: V) -> EnableableView<V>[src]

Creates a new EnableableView around view.

It will be enabled by default.

pub fn disable(&mut self)[src]

Disables this view.

A disabled view cannot be selected.

pub fn disabled(self) -> EnableableView<V>[src]

Disables this view.

Chainable variant.

pub fn enable(&mut self)[src]

Re-enables this view.

pub fn set_enabled(&mut self, enabled: bool)[src]

Enable or disable this view.

pub fn with_enabled(self, is_enabled: bool) -> EnableableView<V>[src]

Enable or disable this view.

Chainable variant.

pub fn is_enabled(&self) -> bool[src]

Returns true if this view is enabled.

pub fn get_inner(&self) -> &V[src]

Gets access to the inner view.

pub fn get_inner_mut(&mut self) -> &mut V[src]

Gets mutable access to the inner view.

Trait Implementations

impl<V> ViewWrapper for EnableableView<V> where
    V: View
[src]

type V = V

Type that this view wraps.

Auto Trait Implementations

impl<V> RefUnwindSafe for EnableableView<V> where
    V: RefUnwindSafe

impl<V> Send for EnableableView<V> where
    V: Send

impl<V> Sync for EnableableView<V> where
    V: Sync

impl<V> Unpin for EnableableView<V> where
    V: Unpin

impl<V> UnwindSafe for EnableableView<V> where
    V: UnwindSafe

Blanket Implementations

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

impl<T> AnyView for T where
    T: View
[src]

fn as_any(&self) -> &(dyn Any + 'static)[src]

Downcast self to a Any.

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]

Downcast self to a mutable Any.

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

impl<T> Finder for T where
    T: View
[src]

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

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

impl<T> IntoBoxedView for T where
    T: View
[src]

impl<T> Nameable for T where
    T: View
[src]

impl<T> Resizable for T where
    T: View
[src]

impl<T> Scrollable for T where
    T: View
[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.

impl<T> View for T where
    T: ViewWrapper
[src]

impl<T> With for T[src]