Struct ambient_ui::button::Button
source · pub struct Button {
pub content: Element,
pub disabled: bool,
pub toggled: bool,
pub style: ButtonStyle,
pub hotkey: Option<VirtualKeyCode>,
pub hotkey_modifier: ModifiersState,
pub tooltip: Option<Element>,
pub on_invoked: ButtonCb,
pub on_is_pressed_changed: Option<Cb<dyn Fn(&mut World, bool) + Sync + Send>>,
}
Expand description
A button UI element.
Fields§
§content: Element
The content of the button; typically text, as provided by one of the constructor functions.
disabled: bool
Whether or not the button is disabled.
toggled: bool
Whether or not the button can be toggled.
style: ButtonStyle
The style of the button.
hotkey: Option<VirtualKeyCode>
The hotkey for the button.
hotkey_modifier: ModifiersState
The hotkey input modifiers for the button.
tooltip: Option<Element>
The tooltip for the button.
on_invoked: ButtonCb
The callback to invoke when the button is pressed.
on_is_pressed_changed: Option<Cb<dyn Fn(&mut World, bool) + Sync + Send>>
The callback to invoke when the current pressed state changes.
Implementations§
source§impl Button
impl Button
sourcepub fn el(
content: Element,
disabled: bool,
toggled: bool,
style: ButtonStyle,
hotkey: Option<VirtualKeyCode>,
hotkey_modifier: ModifiersState,
tooltip: Option<Element>,
on_invoked: ButtonCb,
on_is_pressed_changed: Option<Cb<dyn Fn(&mut World, bool) + Sync + Send>>
) -> Element
pub fn el( content: Element, disabled: bool, toggled: bool, style: ButtonStyle, hotkey: Option<VirtualKeyCode>, hotkey_modifier: ModifiersState, tooltip: Option<Element>, on_invoked: ButtonCb, on_is_pressed_changed: Option<Cb<dyn Fn(&mut World, bool) + Sync + Send>> ) -> Element
Create an Element
from this component.
source§impl Button
impl Button
sourcepub fn new<T: Into<UIElement>>(
content: T,
on_invoked: impl Fn(&mut World) + Sync + Send + 'static
) -> Self
pub fn new<T: Into<UIElement>>( content: T, on_invoked: impl Fn(&mut World) + Sync + Send + 'static ) -> Self
Create a new Button with the given content and callback.
sourcepub fn new_inner<T: Into<UIElement>>(
content: T,
on_invoked: Cb<dyn Fn(&mut World) + Sync + Send + 'static>
) -> Self
pub fn new_inner<T: Into<UIElement>>( content: T, on_invoked: Cb<dyn Fn(&mut World) + Sync + Send + 'static> ) -> Self
sourcepub fn new_once<T: Into<UIElement>>(
content: T,
on_invoked: impl FnOnce(&mut World) + Sync + Send + 'static
) -> Self
pub fn new_once<T: Into<UIElement>>( content: T, on_invoked: impl FnOnce(&mut World) + Sync + Send + 'static ) -> Self
Create a new one-shot Button with the given content and a callback that is only invoked once.
sourcepub fn new_async<F: Future<Output = ()> + Send + 'static, T: Into<UIElement>>(
content: T,
on_invoked: impl Fn() -> F + Sync + Send + 'static
) -> Self
pub fn new_async<F: Future<Output = ()> + Send + 'static, T: Into<UIElement>>( content: T, on_invoked: impl Fn() -> F + Sync + Send + 'static ) -> Self
sourcepub fn new_async_once<F: Future + Send + 'static, T: Into<UIElement>>(
content: T,
on_invoked: impl FnOnce() -> F + Sync + Send + 'static
) -> Self
pub fn new_async_once<F: Future + Send + 'static, T: Into<UIElement>>( content: T, on_invoked: impl FnOnce() -> F + Sync + Send + 'static ) -> Self
sourcepub fn new_value<T: Into<UIElement>, V: PartialEq + Copy + Send + Sync + 'static>(
content: T,
value: V,
set_value: Cb<dyn Fn(V) + Sync + Send>,
desired_value: V
) -> Button
pub fn new_value<T: Into<UIElement>, V: PartialEq + Copy + Send + Sync + 'static>( content: T, value: V, set_value: Cb<dyn Fn(V) + Sync + Send>, desired_value: V ) -> Button
Create a new Button with the given content that sets the given value to the given desired value when clicked.
sourcepub fn style(self, style: ButtonStyle) -> Self
pub fn style(self, style: ButtonStyle) -> Self
Set the style of the button.
sourcepub fn hotkey(self, hotkey: VirtualKeyCode) -> Self
pub fn hotkey(self, hotkey: VirtualKeyCode) -> Self
Set the hotkey of the button.
sourcepub fn hotkey_modifier(self, hotkey_modifier: ModifiersState) -> Self
pub fn hotkey_modifier(self, hotkey_modifier: ModifiersState) -> Self
Set the modifiers for the hotkey of the button.