15 default:
return "unknown";
20key_event::key_event(
unsigned short _key,
KeyAction _action,
unsigned char _char,
unsigned char _modifiers,
unsigned char _toggle_keys,
double _time,
int _x,
int _y)
21 :
event(
EID_KEY,_modifiers, _toggle_keys, _time), key(_key), action(_action), character(_char), x(_x), y(_y)
47 std::cerr <<
"key_event::stream_in not implemented yet" << std::endl;
virtual void stream_out(std::ostream &os) const
write to stream
unsigned char get_char() const
return the key as a character
short get_x() const
current mouse x position (origin is top-left of window)
short x
x position of mouse pointer
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
void set_action(KeyAction _action)
set the key event action
unsigned char character
store the corresponding ascii character
void set_key(unsigned short _key)
set the key
short get_y() const
current mouse y position (origin is top-left of window)
void set_char(unsigned char _char)
set the alpha numeric character
unsigned char action
store whether
void stream_in(std::istream &is)
read from stream
void stream_out(std::ostream &os) const
write to stream
unsigned short key
store the pressed key
unsigned short get_key() const
return the key being a capital letter, digit or a value from the Keys enum
KeyAction get_action() const
return the key event action
short y
y position of mouse pointer
KeyAction
different actions that a key can perform
@ KA_REPEAT
key repeated press action
@ KA_PRESS
key press action
@ KA_RELEASE
key release action
std::string get_key_action_string(KeyAction action)
convert a key action into a readable string
@ EID_KEY
id for key event
std::string get_key_string(unsigned short key)
convert a key code into a readable string