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) + Send + Sync>>>,
}
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) + Send + Sync>>>
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) + Send + Sync>>>
) -> 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) + Send + Sync>>> ) -> 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
) -> Buttonwhere
T: Into<UIElement>,
pub fn new<T>( content: T, on_invoked: impl Fn(&mut World) + Sync + Send + 'static ) -> Buttonwhere T: Into<UIElement>,
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) + Send + Sync>>
) -> Buttonwhere
T: Into<UIElement>,
pub fn new_inner<T>( content: T, on_invoked: Arc<CbDebuggable<dyn Fn(&mut World) + Send + Sync>> ) -> Buttonwhere T: Into<UIElement>,
sourcepub fn new_once<T>(
content: T,
on_invoked: impl FnOnce(&mut World) + Sync + Send + 'static
) -> Buttonwhere
T: Into<UIElement>,
pub fn new_once<T>( content: T, on_invoked: impl FnOnce(&mut World) + Sync + Send + 'static ) -> Buttonwhere T: Into<UIElement>,
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
) -> Buttonwhere
F: Future<Output = ()> + Send + 'static,
T: Into<UIElement>,
pub fn new_async<F, T>( content: T, on_invoked: impl Fn() -> F + Sync + Send + 'static ) -> Buttonwhere F: Future<Output = ()> + Send + 'static, T: Into<UIElement>,
sourcepub fn new_async_once<F, T>(
content: T,
on_invoked: impl FnOnce() -> F + Sync + Send + 'static
) -> Buttonwhere
F: Future + Send + 'static,
T: Into<UIElement>,
pub fn new_async_once<F, T>( content: T, on_invoked: impl FnOnce() -> F + Sync + Send + 'static ) -> Buttonwhere F: Future + Send + 'static, T: Into<UIElement>,
sourcepub fn new_value<T, V>(
content: T,
value: V,
set_value: Arc<CbDebuggable<dyn Fn(V) + Send + Sync>>,
desired_value: V
) -> Buttonwhere
T: Into<UIElement>,
V: PartialEq + Copy + Send + Sync + 'static,
pub fn new_value<T, V>( content: T, value: V, set_value: Arc<CbDebuggable<dyn Fn(V) + Send + Sync>>, desired_value: V ) -> Buttonwhere T: Into<UIElement>, V: PartialEq + Copy + Send + Sync + 'static,
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Button
impl Send for Button
impl Sync for Button
impl Unpin for Button
impl !UnwindSafe for Button
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where T: AsAny,
Any
.