TGUI  0.9-beta
Event.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2019 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_EVENT_HPP
27 #define TGUI_EVENT_HPP
28 
30 
31 namespace tgui
32 {
34 
35  // Based on sf::Event from SFML
36  struct Event
37  {
38  // Based on sf::KeyBoard::Key from SFML
40  enum class KeyboardKey
41  {
42  Unknown = -1,
43  A = 0,
44  B,
45  C,
46  D,
47  E,
48  F,
49  G,
50  H,
51  I,
52  J,
53  K,
54  L,
55  M,
56  N,
57  O,
58  P,
59  Q,
60  R,
61  S,
62  T,
63  U,
64  V,
65  W,
66  X,
67  Y,
68  Z,
69  Num0,
70  Num1,
71  Num2,
72  Num3,
73  Num4,
74  Num5,
75  Num6,
76  Num7,
77  Num8,
78  Num9,
79  Escape,
80  LControl,
81  LShift,
82  LAlt,
83  LSystem,
84  RControl,
85  RShift,
86  RAlt,
87  RSystem,
88  Menu,
89  LBracket,
90  RBracket,
91  Semicolon,
92  Comma,
93  Period,
94  Quote,
95  Slash,
96  Backslash,
97  Tilde,
98  Equal,
99  Minus,
100  Space,
101  Enter,
102  Backspace,
103  Tab,
104  PageUp,
105  PageDown,
106  End,
107  Home,
108  Insert,
109  Delete,
110  Add,
111  Subtract,
112  Multiply,
113  Divide,
114  Left,
115  Right,
116  Up,
117  Down,
118  Numpad0,
119  Numpad1,
120  Numpad2,
121  Numpad3,
122  Numpad4,
123  Numpad5,
124  Numpad6,
125  Numpad7,
126  Numpad8,
127  Numpad9,
128  F1,
129  F2,
130  F3,
131  F4,
132  F5,
133  F6,
134  F7,
135  F8,
136  F9,
137  F10,
138  F11,
139  F12,
140  F13,
141  F14,
142  F15,
143  Pause
144  };
145 
147  enum class MouseButton
148  {
149  Left,
150  Right,
151  Middle
152  };
153 
155  enum class KeyModifier
156  {
157  System,
158  Control,
159  Shift,
160  Alt
161  };
162 
166  struct KeyEvent
167  {
169  bool alt;
170  bool control;
171  bool shift;
172  bool system;
173  };
174 
178  struct TextEvent
179  {
180  char32_t unicode;
181  };
182 
187  {
188  int x;
189  int y;
190  };
191 
196  {
198  int x;
199  int y;
200  };
201 
206  {
207  float delta;
208  int x;
209  int y;
210  };
211 
215  struct SizeEvent
216  {
217  unsigned int width;
218  unsigned int height;
219  };
220 
224  enum class Type
225  {
226  LostFocus,
227  GainedFocus,
228  TextEntered,
229  KeyPressed,
233  MouseMoved,
234  Resized
235  };
236 
238 
240 
241  union
242  {
249  };
250  };
251 
253 }
254 
256 
257 #endif // TGUI_EVENT_HPP
@ Subtract
The - key (minus from numpad)
@ Right
The right mouse button.
@ Delete
The Delete key.
MouseButton button
Code of the button that has been pressed.
Definition: Event.hpp:197
KeyboardKey code
Code of the key that has been pressed.
Definition: Event.hpp:168
Type
Enumeration of the different types of events.
Definition: Event.hpp:225
KeyboardKey
Keyboard key codes.
Definition: Event.hpp:41
MouseMoved event parameters.
Definition: Event.hpp:187
@ Numpad8
The numpad 8 key.
char32_t unicode
UTF-32 Unicode value of the character.
Definition: Event.hpp:180
@ RSystem
The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
Type type
Type of the event.
Definition: Event.hpp:239
@ PageUp
The Page up key.
@ Pause
The Pause key.
Resized events parameters.
Definition: Event.hpp:216
@ RControl
The right Control key.
Definition: Event.hpp:37
@ LControl
The left Control key.
@ GainedFocus
The window gained the focus (no data)
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
@ Numpad4
The numpad 4 key.
KeyModifier
Modifiers keys.
Definition: Event.hpp:156
MouseWheelScrolled events parameters.
Definition: Event.hpp:206
@ MouseWheelScrolled
The mouse wheel was scrolled (data in event.mouseWheel)
@ RShift
The right Shift key.
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:198
@ MouseButtonPressed
A mouse button was pressed (data in event.mouseButton)
@ Unknown
Unhandled key.
@ KeyPressed
A key was pressed (data in event.key)
@ LShift
The left Shift key.
MouseWheelEvent mouseWheel
Mouse wheel event parameters (Event::MouseWheelScrolled)
Definition: Event.hpp:247
@ PageDown
The Page down key.
MouseMoveEvent mouseMove
Mouse move event parameters (Event::MouseMoved)
Definition: Event.hpp:245
@ LSystem
The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:189
@ Numpad5
The numpad 5 key.
bool control
Is the Control key pressed?
Definition: Event.hpp:170
TextEvent text
Text event parameters (Event::TextEntered)
Definition: Event.hpp:244
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:209
SizeEvent size
Size event parameters (Event::Resized)
Definition: Event.hpp:248
@ Minus
The - key (hyphen)
@ Numpad7
The numpad 7 key.
@ Left
The left mouse button.
TextEntered event parameters.
Definition: Event.hpp:179
@ MouseMoved
The mouse cursor moved (data in event.mouseMove)
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:199
MouseButtonEvent mouseButton
Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)
Definition: Event.hpp:246
@ Numpad2
The numpad 2 key.
@ Middle
The middle (wheel) mouse button.
@ LostFocus
The window lost the focus (no data)
@ Numpad6
The numpad 6 key.
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:208
KeyPressed event parameters.
Definition: Event.hpp:167
@ Numpad3
The numpad 3 key.
bool system
Is the System key pressed?
Definition: Event.hpp:172
@ LAlt
The left Alt key.
@ Space
The Space key.
float delta
Wheel offset (positive is up, negative is down). High-precision mice may use non-integral offsets.
Definition: Event.hpp:207
@ Backspace
The Backspace key.
@ Numpad0
The numpad 0 key.
@ Numpad1
The numpad 1 key.
unsigned int height
New height, in pixels.
Definition: Event.hpp:218
@ Resized
The window was resized (data in event.size)
bool shift
Is the Shift key pressed?
Definition: Event.hpp:171
@ Escape
The Escape key.
@ Numpad9
The numpad 9 key.
@ MouseButtonReleased
A mouse button was released (data in event.mouseButton)
MouseButton
Mouse buttons.
Definition: Event.hpp:148
KeyEvent key
Key event parameters (Event::KeyPressed)
Definition: Event.hpp:243
@ Tab
The Tabulation key.
@ Enter
The Enter/Return keys.
unsigned int width
New width, in pixels.
Definition: Event.hpp:217
MouseButtonPressed/MouseButtonReleased events parameters.
Definition: Event.hpp:196
@ RAlt
The right Alt key.
bool alt
Is the Alt key pressed?
Definition: Event.hpp:169
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:188
@ TextEntered
A character was entered (data in event.text)
@ Insert
The Insert key.