#include "KEvent.hpp" ➔ class KEvent

KEvent

KEvent is a class that holds events occurring on a KWindow

class KEvent {
    struct {
        int x, y;
        bool l, m, r;
    } mouse;
    bool close;
    bool quit;
    bool operator[](KKey::Id keyId)
};

Member

struct {
    int x, y;
    bool l, m, r;
} mouse;

A struct that holds mouse state.
x and y store the position of the mouse pointer on the KWindow.
l, m and r store which button have been pressed (left, middle or right).

bool close;
bool quit;

Two boolean indicating if a close or quit event occurred.

Method

KKey::Id get_key();

Returns one of the pressed key.

void update();

Fills the class with events that occurred since the last update.

Operator

bool operator[](KKey::Id keyId)

Returns whether the specified key has been pressed or not.

Example

KWindow window("example", 256, 256);
window.event.update();

std::cout << window.event.mouse.x << " - " << window.event.mouse.y << std::endl;

if (window.event[KKey::Escape]) {
    std::cout << "Escape key pressed." << std::endl;
}