Trait Button

Source
pub trait Button: Widget {
    // Required methods
    fn accel(&self) -> char;
    fn result(&self) -> ButtonResult;

    // Provided methods
    fn pressed(&mut self) { ... }
    fn state(&self) -> bool { ... }
}
Expand description

Trait used when designing new buttons. All buttons implement some key that is recorded, and returns some result that can be matched to run some action

Required Methods§

Source

fn accel(&self) -> char

Return the char that is acting as the key in the Button

Source

fn result(&self) -> ButtonResult

Return the ButtonResult which would be returned if the key is detected

Provided Methods§

Source

fn pressed(&mut self)

If a button is to do some special action upon being pressed, then this function will do so. StdButton for example does nothing when pressed, while CheckButton changes it’s ballot

Source

fn state(&self) -> bool

If a button has a state involved, e.g. needs to keep track of a certain event, this function will return the state of the button.

Implementors§