Struct ambient_api::prelude::Hotkey
source · pub struct Hotkey {
pub hotkey: VirtualKeyCode,
pub hotkey_modifier: ModifiersState,
pub on_is_pressed_changed: Option<Arc<CbDebuggable<dyn Fn(bool) + Sync + Send>>>,
pub on_invoke: Arc<CbDebuggable<dyn Fn(&mut World) + Sync + Send>>,
pub content: Element,
}
Expand description
An element that will invoke a callback when a hotkey is pressed.
Fields§
§hotkey: VirtualKeyCode
The hotkey that will invoke the callback.
hotkey_modifier: ModifiersState
The keyboard modifiers for the hotkey.
on_is_pressed_changed: Option<Arc<CbDebuggable<dyn Fn(bool) + Sync + Send>>>
The callback that is invoked when the current state of the hotkey changes.
on_invoke: Arc<CbDebuggable<dyn Fn(&mut World) + Sync + Send>>
The callback that is invoked when the hotkey is pressed.
content: Element
What to render for this element.
Implementations§
source§impl Hotkey
impl Hotkey
sourcepub fn new(
hotkey: VirtualKeyCode,
on_invoke: impl Fn(&mut World) + Sync + Send + 'static,
content: Element
) -> Hotkey
pub fn new( hotkey: VirtualKeyCode, on_invoke: impl Fn(&mut World) + Sync + Send + 'static, content: Element ) -> Hotkey
Create a new Hotkey with the given content and callback.
sourcepub fn hotkey_modifier(self, hotkey_modifier: ModifiersState) -> Hotkey
pub fn hotkey_modifier(self, hotkey_modifier: ModifiersState) -> Hotkey
Set the keyboard modifiers for the hotkey.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Hotkey
impl Send for Hotkey
impl Sync for Hotkey
impl Unpin for Hotkey
impl !UnwindSafe for Hotkey
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
Mutably borrows from an owned value. Read more
source§impl<T> Downcast for T
impl<T> Downcast for T
source§impl<T> ElementComponentExt for Twhere
T: ElementComponent + 'static,
impl<T> ElementComponentExt for Twhere
T: ElementComponent + 'static,
source§impl<T> ElementComponentName for T
impl<T> ElementComponentName for T
source§fn element_component_name(&self) -> &'static str
fn element_component_name(&self) -> &'static str
Returns the name of the type implementing ElementComponent.