Struct tuix::Button [−]
Expand description
A basic button widget with an optional label.
A Widget that can be pressed and released and may emit an event on_press and on_release. The button can also be triggered with a keyboard key (default space bar).
Example
Create a button which closes the window when pressed:
Button::new()
.on_press(|_, state, button| {
button.emit(state, WindowEvent::CloseWindow);
})
.build(state, parent, |builder| builder);
Fields
text: Option<String>
Implementations
impl Button
impl Button
Create a new button widget with no callbacks.
Example
Button::new().build(state, parent, |builder| builder);
pub fn with_label(text: &str) -> Button
pub fn with_label(text: &str) -> Button
Create a new button widget with a specified text label.
Example
Button::with_label("A Button").build(state, parent, |builder| builder);
Set the callback triggered when the button is pressed.
Example
Creates a button which closes the window when pressed:
Button::new()
.on_press(|_, state, button| {
button.emit(state, WindowEvent::CloseWindow);
})
.build(state, parent, |builder| builder);
Set the callback triggered when the button is released.
Example
Create a button which closes the window when released:
Button::new()
.on_release(|_, state, button| {
button.emit(state, WindowEvent::CloseWindow);
})
.build(state, parent, |builder| builder);
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Button
impl !UnwindSafe for Button
Blanket Implementations
Mutably borrows from an owned value. Read more