pub struct NativeEventHandler { /* private fields */ }
Expand description
Decide whether to notify other programs of generated events.
Implementations§
Source§impl NativeEventHandler
impl NativeEventHandler
Sourcepub fn handle(self, operation: NativeEventOperation)
pub fn handle(self, operation: NativeEventOperation)
Decides whether or not to notify by argument.
Sourcepub fn dispatch(self)
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}
Sourcepub fn block(self)
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
impl Debug for NativeEventHandler
Auto Trait Implementations§
impl Freeze for NativeEventHandler
impl RefUnwindSafe for NativeEventHandler
impl Send for NativeEventHandler
impl Sync for NativeEventHandler
impl Unpin for NativeEventHandler
impl UnwindSafe for NativeEventHandler
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