Struct tuix_internal::buttons::button::Button [−][src]
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
Create a new button widget with no callbacks.
Example
Button::new().build(state, parent, |builder| builder);
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);