Struct ambient_ui_native::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 + 'static>>>,
}
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 + 'static>>>
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 + 'static>>>
) -> 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 + 'static>>> ) -> 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) + Sync + Send + 'static>>
) -> Buttonwhere
T: Into<UIElement>,
pub fn new_inner<T>( content: T, on_invoked: Arc<CbDebuggable<dyn Fn(&mut World) + Sync + Send + 'static>> ) -> 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) + Sync + Send + 'static>>,
desired_value: V
) -> Buttonwhere
T: Into<UIElement>,
V: PartialEq<V> + Copy + Send + Sync + 'static,
pub fn new_value<T, V>( content: T, value: V, set_value: Arc<CbDebuggable<dyn Fn(V) + Sync + Send + 'static>>, desired_value: V ) -> Buttonwhere T: Into<UIElement>, V: PartialEq<V> + 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
source§impl<T> ComponentValueBase for Twhere
T: Send + Sync + 'static,
impl<T> ComponentValueBase for Twhere T: Send + Sync + 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.