TGUI  0.9.1
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  Closed
236  };
237 
239 
241 
242  union
243  {
250  };
251  };
252 
254 }
255 
257 
258 #endif // TGUI_EVENT_HPP
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
KeyPressed event parameters.
Definition: Event.hpp:167
KeyboardKey code
Code of the key that has been pressed.
Definition: Event.hpp:168
bool system
Is the System key pressed?
Definition: Event.hpp:172
bool control
Is the Control key pressed?
Definition: Event.hpp:170
bool alt
Is the Alt key pressed?
Definition: Event.hpp:169
bool shift
Is the Shift key pressed?
Definition: Event.hpp:171
MouseButtonPressed/MouseButtonReleased events parameters.
Definition: Event.hpp:196
MouseButton button
Code of the button that has been pressed.
Definition: Event.hpp:197
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:198
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:199
MouseMoved event parameters.
Definition: Event.hpp:187
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:189
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:188
MouseWheelScrolled events parameters.
Definition: Event.hpp:206
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:208
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:209
float delta
Wheel offset (positive is up, negative is down). High-precision mice may use non-integral offsets.
Definition: Event.hpp:207
Resized events parameters.
Definition: Event.hpp:216
unsigned int width
New width, in pixels.
Definition: Event.hpp:217
unsigned int height
New height, in pixels.
Definition: Event.hpp:218
TextEntered event parameters.
Definition: Event.hpp:179
char32_t unicode
UTF-32 Unicode value of the character.
Definition: Event.hpp:180
Definition: Event.hpp:37
Type type
Type of the event.
Definition: Event.hpp:240
MouseButton
Mouse buttons.
Definition: Event.hpp:148
@ Right
The right mouse button.
@ Left
The left mouse button.
@ Middle
The middle (wheel) mouse button.
KeyModifier
Modifiers keys.
Definition: Event.hpp:156
MouseWheelEvent mouseWheel
Mouse wheel event parameters (Event::MouseWheelScrolled)
Definition: Event.hpp:248
KeyboardKey
Keyboard key codes.
Definition: Event.hpp:41
@ Escape
The Escape key.
@ RAlt
The right Alt key.
@ Pause
The Pause key.
@ Numpad9
The numpad 9 key.
@ Numpad0
The numpad 0 key.
@ Subtract
The - key (minus from numpad)
@ RSystem
The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
@ Numpad7
The numpad 7 key.
@ Minus
The - key (hyphen)
@ Numpad6
The numpad 6 key.
@ Numpad4
The numpad 4 key.
@ Tab
The Tabulation key.
@ Numpad3
The numpad 3 key.
@ Numpad5
The numpad 5 key.
@ LShift
The left Shift key.
@ Unknown
Unhandled key.
@ Numpad8
The numpad 8 key.
@ RShift
The right Shift key.
@ PageUp
The Page up key.
@ LControl
The left Control key.
@ Insert
The Insert key.
@ LAlt
The left Alt key.
@ RControl
The right Control key.
@ Numpad1
The numpad 1 key.
@ Backspace
The Backspace key.
@ Space
The Space key.
@ PageDown
The Page down key.
@ Enter
The Enter/Return keys.
@ Delete
The Delete key.
@ Numpad2
The numpad 2 key.
@ LSystem
The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
MouseMoveEvent mouseMove
Mouse move event parameters (Event::MouseMoved)
Definition: Event.hpp:246
MouseButtonEvent mouseButton
Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)
Definition: Event.hpp:247
TextEvent text
Text event parameters (Event::TextEntered)
Definition: Event.hpp:245
Type
Enumeration of the different types of events.
Definition: Event.hpp:225
@ Closed
The window was closed.
@ Resized
The window was resized (data in event.size)
@ GainedFocus
The window gained the focus (no data)
@ MouseButtonPressed
A mouse button was pressed (data in event.mouseButton)
@ MouseButtonReleased
A mouse button was released (data in event.mouseButton)
@ LostFocus
The window lost the focus (no data)
@ TextEntered
A character was entered (data in event.text)
@ MouseWheelScrolled
The mouse wheel was scrolled (data in event.mouseWheel)
@ KeyPressed
A key was pressed (data in event.key)
@ MouseMoved
The mouse cursor moved (data in event.mouseMove)
KeyEvent key
Key event parameters (Event::KeyPressed)
Definition: Event.hpp:244
SizeEvent size
Size event parameters (Event::Resized)
Definition: Event.hpp:249