HotkeyManager

Struct HotkeyManager 

Source
pub struct HotkeyManager<T> { /* private fields */ }

Implementations§

Source§

impl<T> HotkeyManager<T>

Source

pub fn set_no_repeat(&mut self, no_repeat: bool)

Enable or disable the automatically applied ModKey::NoRepeat modifier. By default, this option is set to true which causes all hotkey registration calls to add the NoRepeat modifier, thereby disabling automatic retriggers of hotkeys when holding down the keys.

When this option is disabled, the ModKey::NoRepeat can still be manually added while registering hotkeys.

Note: Setting this flag doesn’t change previously registered hotkeys. It only applies to registrations performed after calling this function.

Trait Implementations§

Source§

impl<T: Debug> Debug for HotkeyManager<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for HotkeyManager<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Drop for HotkeyManager<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> HotkeyManagerImpl<T> for HotkeyManager<T>

Source§

fn new() -> HotkeyManager<T>

Source§

fn register_extrakeys( &mut self, virtual_key: VirtualKey, modifiers_key: Option<&[ModifiersKey]>, extra_keys: Option<&[VirtualKey]>, callback: Option<impl Fn() -> T + Send + 'static>, ) -> Result<HotkeyId, HotkeyError>

Register a new hotkey with additional required extra keys. Read more
Source§

fn register( &mut self, virtual_key: VirtualKey, modifiers_key: Option<&[ModifiersKey]>, callback: Option<impl Fn() -> T + Send + 'static>, ) -> Result<HotkeyId, HotkeyError>

Same as register_extrakeys but without extra keys. Read more
Source§

fn unregister(&mut self, id: HotkeyId) -> Result<(), HotkeyError>

Unregister a hotkey. This will prevent the hotkey from being triggered in the future. Read more
Source§

fn unregister_all(&mut self) -> Result<(), HotkeyError>

Unregister all registered hotkeys. This will be called automatically when dropping the HotkeyManager instance. Read more
Source§

fn handle_hotkey(&self) -> Option<T>

Wait for a single a hotkey event and execute the callback if all keys match. This returns the callback result if it was not interrupted. The function call will block until a hotkey is triggered or it is interrupted. Read more
Source§

fn event_loop(&self)

Run the event loop, listening for hotkeys. This will run indefinitely until interrupted and execute any hotkeys registered before.
Source§

fn interrupt_handle(&self) -> InterruptHandle

Get an InterruptHandle for this HotkeyManager that can be used to interrupt the event loop.
Source§

impl<T> Send for HotkeyManager<T>

Source§

impl<T> Sync for HotkeyManager<T>

Auto Trait Implementations§

§

impl<T> Freeze for HotkeyManager<T>

§

impl<T> !RefUnwindSafe for HotkeyManager<T>

§

impl<T> Unpin for HotkeyManager<T>

§

impl<T> !UnwindSafe for HotkeyManager<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.