Struct NativeEventHandler

Source
pub struct NativeEventHandler { /* private fields */ }
Expand description

Decide whether to notify other programs of generated events.

Implementations§

Source§

impl NativeEventHandler

Source

pub fn handle(self, operation: NativeEventOperation)

Decides whether or not to notify by argument.

Source

pub fn dispatch(self)

Examples found in repository?
examples/readme_core.rs (line 9)
3fn main() {
4    let rx = hookmap_core::install_hook();
5
6    while let Ok((event, native_handler)) = rx.recv() {
7        match event {
8            Event::Button(event) => {
9                native_handler.dispatch();
10
11                match event.target {
12                    Button::RightArrow => println!("Left"),
13                    Button::UpArrow => println!("Up"),
14                    Button::LeftArrow => println!("Right"),
15                    Button::DownArrow => println!("Down"),
16                    _ => {}
17                };
18            }
19
20            Event::Cursor(e) => {
21                native_handler.block();
22
23                // Reverses mouse cursor movement
24                let (dx, dy) = e.delta;
25                mouse::move_relative(-dx, -dy);
26            }
27
28            Event::Wheel(e) => {
29                native_handler.dispatch();
30                println!("delta: {}", e.delta);
31            }
32        }
33    }
34}
Source

pub fn block(self)

Examples found in repository?
examples/readme_core.rs (line 21)
3fn main() {
4    let rx = hookmap_core::install_hook();
5
6    while let Ok((event, native_handler)) = rx.recv() {
7        match event {
8            Event::Button(event) => {
9                native_handler.dispatch();
10
11                match event.target {
12                    Button::RightArrow => println!("Left"),
13                    Button::UpArrow => println!("Up"),
14                    Button::LeftArrow => println!("Right"),
15                    Button::DownArrow => println!("Down"),
16                    _ => {}
17                };
18            }
19
20            Event::Cursor(e) => {
21                native_handler.block();
22
23                // Reverses mouse cursor movement
24                let (dx, dy) = e.delta;
25                mouse::move_relative(-dx, -dy);
26            }
27
28            Event::Wheel(e) => {
29                native_handler.dispatch();
30                println!("delta: {}", e.delta);
31            }
32        }
33    }
34}

Trait Implementations§

Source§

impl Debug for NativeEventHandler

Source§

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

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

impl Drop for NativeEventHandler

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.