Skip to main content

Config

Struct Config 

Source
pub struct Config<T = KeyboardEvent> {
    pub on_released: Box<OnReleasedFn<T>>,
}
Expand description

Configuration for the event handler’s behavior.

Used to define how to handle a modifier key after it has been pressed and released. For example, you can specify a callback to send a dummy key to prevent menu activation.

By default, it returns Some(VK__none_) to always suppress menu activation.

Fields§

§on_released: Box<OnReleasedFn<T>>

A callback invoked when a key is released after being pressed.

Implementations§

Source§

impl<T> Config<T>

Source

pub fn set_on_released<F: Fn(HoldEvent<T>) -> Option<VIRTUAL_KEY> + Send + Sync + 'static>( self, f: F, ) -> Self

Sets the callback function to be invoked when a key is released.

This method updates the on_released field with the provided function, which takes a HoldEvent representing the press and release of a modifier key. The callback should return a dummy VIRTUAL_KEY to send, or None if no key should be sent.

§Arguments
  • f: A closure or function of type Fn(HoldEvent<T>) -> Option<VIRTUAL_KEY>.
§Returns

A modified Config instance with the new callback set (builder pattern).

Trait Implementations§

Source§

impl<T> Default for Config<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T = KeyboardEvent> !RefUnwindSafe for Config<T>

§

impl<T = KeyboardEvent> !UnwindSafe for Config<T>

§

impl<T> Freeze for Config<T>
where Box<dyn Fn(HoldEvent<T>) -> Option<VIRTUAL_KEY> + Send + Sync>: Freeze,

§

impl<T> Send for Config<T>
where Box<dyn Fn(HoldEvent<T>) -> Option<VIRTUAL_KEY> + Send + Sync>: Send,

§

impl<T> Sync for Config<T>
where Box<dyn Fn(HoldEvent<T>) -> Option<VIRTUAL_KEY> + Send + Sync>: Sync,

§

impl<T> Unpin for Config<T>
where Box<dyn Fn(HoldEvent<T>) -> Option<VIRTUAL_KEY> + Send + Sync>: Unpin,

§

impl<T> UnsafeUnpin for Config<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.