Struct glerminal::Events

source ·
pub struct Events {
    pub keyboard: Input<VirtualKeyCode>,
    pub mouse: Input<MouseButton>,
    pub cursor: Cursor,
}
Expand description

Represents all the events that happen in glerminal, such as keyboard events, mouse events, resize, and close events.

Example usage:

use glerminal::{TerminalBuilder, VirtualKeyCode, TextBuffer};

let terminal = TerminalBuilder::new()
    .with_title("Hello GLerminal!")
    .with_dimensions((1280, 720))
    .build();

let mut text_buffer;
match TextBuffer::new(&terminal, (80, 24)) {
    Ok(buffer) => text_buffer = buffer,
    Err(error) => panic!(format!("Failed to initialize text buffer: {}", error)),
}

let events = terminal.get_current_events();
println!("Was A just pressed: {}", events.keyboard.was_just_pressed(VirtualKeyCode::A));
println!("Cursor position: {:?}", events.cursor.get_location(&text_buffer));

Fields§

§keyboard: Input<VirtualKeyCode>

Represents keyboard events.

§mouse: Input<MouseButton>

Represents mouse events.

§cursor: Cursor

Allows getting information related to cursor position

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.