cgv
key_event.h
1 #pragma once
2 
3 #include "event.h"
4 #include "shortcut.h"
5 
6 #include "lib_begin.h"
7 
8 namespace cgv {
9  namespace gui {
10 
12 enum KeyAction {
15  KA_REPEAT
16 };
17 
19 extern CGV_API std::string get_key_action_string(KeyAction action);
20 
22 class CGV_API key_event : public event
23 {
24 protected:
26  unsigned short key;
28  unsigned char action;
30  unsigned char character;
31 public:
33  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);
35  void stream_out(std::ostream& os) const;
37  void stream_in(std::istream& is);
39  unsigned short get_key() const;
41  void set_key(unsigned short _key);
43  KeyAction get_action() const;
45  void set_action(KeyAction _action);
47  unsigned char get_char() const;
49  void set_char(unsigned char _char);
50 };
51 
52  }
53 }
54 
55 #include <cgv/config/lib_end.h>
cgv::gui::key_event::key
unsigned short key
store the pressed key
Definition: key_event.h:26
cgv::gui::key_event
class to represent all possible keyboard events with the EID_KEY
Definition: key_event.h:23
cgv::gui::KA_RELEASE
@ KA_RELEASE
key release action
Definition: key_event.h:13
cgv::gui::key_event::character
unsigned char character
store the corresponding ascii character
Definition: key_event.h:30
cgv::gui::KeyAction
KeyAction
different actions that a key can perform
Definition: key_event.h:12
cgv::gui::KA_REPEAT
@ KA_REPEAT
key repeated press action
Definition: key_event.h:15
cgv::gui::key_event::action
unsigned char action
store whether
Definition: key_event.h:28
cgv::gui::event
Definition: event.h:59
cgv::gui::KA_PRESS
@ KA_PRESS
key press action
Definition: key_event.h:14
cgv::gui::get_key_action_string
std::string get_key_action_string(KeyAction action)
convert a key action into a readable string
Definition: key_event.cxx:9
cgv
the cgv namespace
Definition: vr_calib.cxx:9