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>
event(unsigned int _kind=EID_NONE, unsigned char _modifiers=0, unsigned char _toggle_keys=0, double _time=0)
construct event from its kind
Definition event.cxx:20
unsigned char get_char() const
return the key as a character
Definition key_event.cxx:61
short get_x() const
current mouse x position (origin is top-left of window)
Definition key_event.cxx:81
short x
x position of mouse pointer
Definition key_event.h:32
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)
construct a key event from its textual description
Definition key_event.cxx:20
void set_action(KeyAction _action)
set the key event action
Definition key_event.cxx:76
unsigned char character
store the corresponding ascii character
Definition key_event.h:30
void set_key(unsigned short _key)
set the key
Definition key_event.cxx:56
short get_y() const
current mouse y position (origin is top-left of window)
Definition key_event.cxx:86
void set_char(unsigned char _char)
set the alpha numeric character
Definition key_event.cxx:66
unsigned char action
store whether
Definition key_event.h:28
void stream_in(std::istream &is)
read from stream
Definition key_event.cxx:45
void stream_out(std::ostream &os) const
write to stream
Definition key_event.cxx:26
unsigned short key
store the pressed key
Definition key_event.h:26
unsigned short get_key() const
return the key being a capital letter, digit or a value from the Keys enum
Definition key_event.cxx:51
KeyAction get_action() const
return the key event action
Definition key_event.cxx:71
short y
y position of mouse pointer
Definition key_event.h:34
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
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
this header is dependency free
Definition print.h:11