Struct ButtonState

Source
pub struct ButtonState { /* private fields */ }
Expand description

§The state of a Button

§Fields

text: Option<String>
icon_data: Option<String>
icon_extension: Option<String>
disabled: bool
stretched: bool
style: String

Implementations§

Source§

impl ButtonState

Source

pub fn text(&self) -> Option<&str>

Get the text

Source

pub fn icon(&self) -> Option<Pixmap>

Source

pub fn disabled(&self) -> bool

Get the disabled flag

Source

pub fn stretched(&self) -> bool

Get the stretched flag

Source

pub fn style(&self) -> &str

Get the style

Source

pub fn set_text(&mut self, text: &str)

Set the text

Examples found in repository?
examples/add_data.rs (line 41)
40    fn on_update(&self, state: &mut ButtonState) {
41        state.set_text(&self.counter.borrow().value().to_string());
42    }
More examples
Hide additional examples
examples/timer.rs (lines 46-49)
45    fn on_update(&self, state: &mut ButtonState) {
46        state.set_text(&format!(
47            "{} seconds since last reset",
48            self.counter.borrow().value().to_string()
49        ));
50    }
examples/login.rs (line 60)
51    fn on_update(&self, state: &mut ButtonState) {
52        if self.login.borrow().check() {
53            state.set_style(
54                r#"
55                $color: forestgreen;
56                background-color: $color;
57                border-color: $color;
58            "#,
59            );
60            state.set_text("OK");
61        } else {
62            state.set_style(
63                r#"
64                $color: crimson;
65                background-color: $color;
66                border-color: $color;
67            "#,
68            );
69            state.set_text("KO");
70        }
71    }
Source

pub fn set_icon(&mut self, icon: Box<dyn Icon>)

Set the icon

Source

pub fn set_disabled(&mut self, disabled: bool)

Set the disabled flag

Examples found in repository?
examples/demo_mod/listeners.rs (line 198)
197    fn on_update(&self, state: &mut ButtonState) {
198        state.set_disabled(self.state.borrow().disabled());
199    }
Source

pub fn set_stretched(&mut self, stretched: bool)

Set the streched flag

Source

pub fn set_style(&mut self, style: &str)

Set the style

Examples found in repository?
examples/login.rs (lines 53-59)
51    fn on_update(&self, state: &mut ButtonState) {
52        if self.login.borrow().check() {
53            state.set_style(
54                r#"
55                $color: forestgreen;
56                background-color: $color;
57                border-color: $color;
58            "#,
59            );
60            state.set_text("OK");
61        } else {
62            state.set_style(
63                r#"
64                $color: crimson;
65                background-color: $color;
66                border-color: $color;
67            "#,
68            );
69            state.set_text("KO");
70        }
71    }

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V