Struct ambient_api::input::CursorLockGuard
source · pub struct CursorLockGuard { /* private fields */ }
Expand description
Helper utility that will lock and hide the cursor if necessary.
Will unlock the cursor when dropped.
Implementations§
source§impl CursorLockGuard
impl CursorLockGuard
sourcepub fn new(locked: bool) -> CursorLockGuard
pub fn new(locked: bool) -> CursorLockGuard
Creates a new CursorLockGuard with the given lock state.
sourcepub fn set_locked(&mut self, locked: bool)
pub fn set_locked(&mut self, locked: bool)
Locks and hides the cursor if necessary.
sourcepub fn lock(&mut self)
pub fn lock(&mut self)
Helper that calls Self::set_locked with true
.
sourcepub fn unlock(&mut self)
pub fn unlock(&mut self)
Helper that calls Self::set_locked with false
.
sourcepub fn auto_unlock_on_escape(&mut self, input: &Input) -> bool
pub fn auto_unlock_on_escape(&mut self, input: &Input) -> bool
Helper that will unlock if Escape
has been pressed, and lock if anything else is pressed.
Returns whether or not the cursor is currently locked.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for CursorLockGuard
impl Send for CursorLockGuard
impl Sync for CursorLockGuard
impl Unpin for CursorLockGuard
impl UnwindSafe for CursorLockGuard
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> 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.