Module message_loop

Source
Expand description

The message_loop module provides a way to retreive keyboard and mouse input messages directly from the system.

Internally, a message-only window is created to receive the messages.

§Examples

use winput::{Vk, Action};
use winput::message_loop;

let receiver = message_loop::start().unwrap();

loop {
    match receiver.next_event() {
        message_loop::Event::Keyboard {
            vk,
            action: Action::Press,
            ..
        } => {
            if vk == Vk::Escape {
                break;
            } else {
                println!("{:?} was pressed!", vk);
            }
        },
        _ => (),
    }
}

Structs§

EventReceiver
The result of the start function. This structure receives the messages received by the message loop.

Enums§

Event
An event of any kind.
MessageLoopError
An error that can be produced by the start function.

Functions§

is_active
Checks if the message loop is currently active. When this function returns true, calling start always produces an error.
start
Starts the message loop on a new thread.
stop
Stops the message loop.