[][src]Struct cursive::views::Button

pub struct Button { /* fields omitted */ }

Simple text label with a callback when is pressed.

A button shows its content in a single line and has a fixed size.

Examples

use cursive_core::views::Button;

let quit_button = Button::new("Quit", |s| s.quit());

Implementations

impl Button[src]

pub fn disable(&mut self)[src]

Disables this view.

A disabled view cannot be selected.

pub fn disabled(self) -> Button[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) -> Button[src]

Enable or disable this view.

Chainable variant.

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

Returns true if this view is enabled.

pub fn new<F, S>(label: S, cb: F) -> Button where
    F: 'static + Fn(&mut Cursive),
    S: Into<String>, 
[src]

Creates a new button with the given content and callback.

pub fn new_raw<F, S>(label: S, cb: F) -> Button where
    F: 'static + Fn(&mut Cursive),
    S: Into<String>, 
[src]

Creates a new button without angle brackets.

Examples

use cursive_core::views::Button;

let button = Button::new_raw("[ Quit ]", |s| s.quit());

pub fn set_callback<F>(&mut self, cb: F) where
    F: Fn(&mut Cursive) + 'static, 
[src]

Sets the function to be called when the button is pressed.

Replaces the previous callback.

pub fn label(&self) -> &str[src]

Returns the label for this button.

Includes brackets.

Examples

let button = Button::new("Quit", |s| s.quit());
assert_eq!(button.label(), "<Quit>");

pub fn set_label<S>(&mut self, label: S) where
    S: Into<String>, 
[src]

Sets the label to the given value.

This will include brackets.

Examples

use cursive_core::views::Button;

let mut button = Button::new("Quit", |s| s.quit());
button.set_label("Escape");

pub fn set_label_raw<S>(&mut self, label: S) where
    S: Into<String>, 
[src]

Sets the label exactly to the given value.

This will not include brackets.

Trait Implementations

impl View for Button[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

Downcast self to a Any.

pub 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> With for T[src]