Char_InputNode.cpp
Go to the documentation of this file.
1 #include "Char_InputNode.hpp"
2 
4 #include "../Defs.hpp"
5 
6 namespace iv
7 {
8 
9 //------------------------- CharListener -----------------------------
11  cm( inst, this, "CharListener" ),
12  inst( inst )
13 {
14 }
15 
17 {
18 }
19 
21 {
22  return this->inst;
23 }
24 
25 //--------------------------- Char_InputNode --------------------------------------------
27  cm( inst, this, "Char_InputEvent" ),
28  InputNode( inst )
29 {
30  this->cm.inherits( this->InputNode::cm );
31 }
32 
34 {
35  this->char_listeners.insert( listener );
36 }
37 
39 {
40  this->char_listeners.erase( listener );
41 }
42 
44 {
45  if( key.first != Input::Key::Character )
46  {
47  this->cm.log( SRC_INFO, Defs::Log::Input, "Refuse input, not a Character input." );
48  return true;
49  }
50 
51  this->cm.log( SRC_INFO, Defs::Log::Input, "Accept Character input." );
52 
53  InputQuery iq( this->instance() );
54  unsigned character = iq.input_character();
55 
56  this->char_listeners.foreach(
57  [&]( CharListener * listener )
58  {
59  listener->on_char( this, character );
60  }
61  );
62 
63  return false;
64 }
65 
66 }