cgv
Loading...
Searching...
No Matches
key_event.h
1#pragma once
2
3#include "event.h"
4#include "shortcut.h"
5
6#include "lib_begin.h"
7
8namespace cgv {
9 namespace gui {
10
17
19extern CGV_API std::string get_key_action_string(KeyAction action);
20
22class CGV_API key_event : public event
23{
24protected:
26 unsigned short key;
28 unsigned char action;
30 unsigned char character;
32 short x;
34 short y;
35public:
37 key_event(unsigned short _key = 0, KeyAction _action = KA_PRESS, unsigned char _char = 0, unsigned char _modifiers = 0, unsigned char _toggle_keys = 0, double _time = 0, int _x = 0, int _y = 0);
39 void stream_out(std::ostream& os) const;
41 void stream_in(std::istream& is);
43 unsigned short get_key() const;
45 void set_key(unsigned short _key);
47 KeyAction get_action() const;
49 void set_action(KeyAction _action);
51 unsigned char get_char() const;
53 void set_char(unsigned char _char);
55 short get_x() const;
57 short get_y() const;
58};
59
60 }
61}
62
63#include <cgv/config/lib_end.h>
class to represent all possible keyboard events with the EID_KEY
Definition key_event.h:23
short x
x position of mouse pointer
Definition key_event.h:32
unsigned char character
store the corresponding ascii character
Definition key_event.h:30
unsigned char action
store whether
Definition key_event.h:28
unsigned short key
store the pressed key
Definition key_event.h:26
short y
y position of mouse pointer
Definition key_event.h:34
KeyAction
different actions that a key can perform
Definition key_event.h:12
@ KA_REPEAT
key repeated press action
Definition key_event.h:15
@ KA_PRESS
key press action
Definition key_event.h:14
@ KA_RELEASE
key release action
Definition key_event.h:13
std::string get_key_action_string(KeyAction action)
convert a key action into a readable string
Definition key_event.cxx:9
the cgv namespace
Definition print.h:11