[−][src]Struct cursive::views::EnableableView
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::Cursive; use cursive::views::{Button, EnableableView, Checkbox, LinearLayout}; use cursive::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) -> Self
[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) -> Self
[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 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: View> ViewWrapper for EnableableView<V>
[src]
type V = V
Type that this view wraps.
fn with_view<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&Self::V) -> R,
[src]
F: FnOnce(&Self::V) -> R,
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R> where
F: FnOnce(&mut Self::V) -> R,
[src]
F: FnOnce(&mut Self::V) -> R,
fn into_inner(self) -> Result<Self::V, Self> where
Self::V: Sized,
[src]
Self::V: Sized,
fn wrap_on_event(&mut self, event: Event) -> EventResult
[src]
fn wrap_draw(&self, printer: &Printer)
[src]
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
[src]
fn wrap_layout(&mut self, size: Vec2)
[src]
fn wrap_take_focus(&mut self, source: Direction) -> bool
[src]
fn wrap_call_on_any<'a>(&mut self, selector: &Selector, callback: AnyCb<'a>)
[src]
fn wrap_focus_view(&mut self, selector: &Selector) -> Result<(), ()>
[src]
fn wrap_needs_relayout(&self) -> bool
[src]
fn wrap_important_area(&self, size: Vec2) -> Rect
[src]
Auto Trait Implementations
impl<V> RefUnwindSafe for EnableableView<V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<V> Send for EnableableView<V> where
V: Send,
V: Send,
impl<V> Sync for EnableableView<V> where
V: Sync,
V: Sync,
impl<V> Unpin for EnableableView<V> where
V: Unpin,
V: Unpin,
impl<V> UnwindSafe for EnableableView<V> where
V: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,