Struct ambient_api::prelude::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<Arc<CbDebuggable<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<Arc<CbDebuggable<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<Arc<CbDebuggable<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<Arc<CbDebuggable<dyn Fn(&mut World, bool) + Sync + Send>>> ) -> Element
Create an Element
from this component.
source§impl Button
impl Button
sourcepub fn new<T>(
content: T,
on_invoked: impl Fn(&mut World) + Sync + Send + 'static
) -> Button
pub fn new<T>( content: T, on_invoked: impl Fn(&mut World) + Sync + Send + 'static ) -> Button
Create a new Button with the given content and callback.
sourcepub fn new_inner<T>(
content: T,
on_invoked: Arc<CbDebuggable<dyn Fn(&mut World) + Sync + Send>>
) -> Button
pub fn new_inner<T>( content: T, on_invoked: Arc<CbDebuggable<dyn Fn(&mut World) + Sync + Send>> ) -> Button
sourcepub fn new_once<T>(
content: T,
on_invoked: impl FnOnce(&mut World) + Sync + Send + 'static
) -> Button
pub fn new_once<T>( content: T, on_invoked: impl FnOnce(&mut World) + Sync + Send + 'static ) -> Button
Create a new one-shot Button with the given content and a callback that is only invoked once.
sourcepub fn new_async<F, T>(
content: T,
on_invoked: impl Fn() -> F + Sync + Send + 'static
) -> Button
pub fn new_async<F, T>( content: T, on_invoked: impl Fn() -> F + Sync + Send + 'static ) -> Button
sourcepub fn new_async_once<F, T>(
content: T,
on_invoked: impl FnOnce() -> F + Sync + Send + 'static
) -> Button
pub fn new_async_once<F, T>( content: T, on_invoked: impl FnOnce() -> F + Sync + Send + 'static ) -> Button
sourcepub fn new_value<T, V>(
content: T,
value: V,
set_value: Arc<CbDebuggable<dyn Fn(V) + Sync + Send>>,
desired_value: V
) -> Button
pub fn new_value<T, V>( content: T, value: V, set_value: Arc<CbDebuggable<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) -> Button
pub fn style(self, style: ButtonStyle) -> Button
Set the style of the button.
sourcepub fn hotkey(self, hotkey: VirtualKeyCode) -> Button
pub fn hotkey(self, hotkey: VirtualKeyCode) -> Button
Set the hotkey of the button.
sourcepub fn hotkey_modifier(self, hotkey_modifier: ModifiersState) -> Button
pub fn hotkey_modifier(self, hotkey_modifier: ModifiersState) -> Button
Set the modifiers for the hotkey of the button.