SFML - Simple and Fast Multimedia Library

SFML 2.4.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

Event.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
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 #ifndef SFML_EVENT_HPP
26 #define SFML_EVENT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32 #include <SFML/Window/Joystick.hpp>
33 #include <SFML/Window/Keyboard.hpp>
34 #include <SFML/Window/Mouse.hpp>
35 #include <SFML/Window/Sensor.hpp>
36
37
38 namespace sf
39 {
44 class Event
45 {
46 public:
47
52 struct SizeEvent
53 {
54 unsigned int width;
55 unsigned int height;
56 };
57
62 struct KeyEvent
63 {
64 Keyboard::Key code;
65 bool alt;
66 bool control;
67 bool shift;
68 bool system;
69 };
70
75 struct TextEvent
76 {
77 Uint32 unicode;
78 };
79
84 struct MouseMoveEvent
85 {
86 int x;
87 int y;
88 };
89
95 struct MouseButtonEvent
96 {
97 Mouse::Button button;
98 int x;
99 int y;
100 };
101
109 struct MouseWheelEvent
110 {
111 int delta;
112 int x;
113 int y;
114 };
115
120 struct MouseWheelScrollEvent
121 {
122 Mouse::Wheel wheel;
123 float delta;
124 int x;
125 int y;
126 };
127
133 struct JoystickConnectEvent
134 {
135 unsigned int joystickId;
136 };
137
142 struct JoystickMoveEvent
143 {
144 unsigned int joystickId;
145 Joystick::Axis axis;
146 float position;
147 };
148
154 struct JoystickButtonEvent
155 {
156 unsigned int joystickId;
157 unsigned int button;
158 };
159
164 struct TouchEvent
165 {
166 unsigned int finger;
167 int x;
168 int y;
169 };
170
175 struct SensorEvent
176 {
177 Sensor::Type type;
178 float x;
179 float y;
180 float z;
181 };
182
187 enum EventType
188 {
189 Closed,
190 Resized,
191 LostFocus,
192 GainedFocus,
193 TextEntered,
194 KeyPressed,
195 KeyReleased,
196 MouseWheelMoved,
197 MouseWheelScrolled,
198 MouseButtonPressed,
199 MouseButtonReleased,
200 MouseMoved,
201 MouseEntered,
202 MouseLeft,
203 JoystickButtonPressed,
204 JoystickButtonReleased,
205 JoystickMoved,
206 JoystickConnected,
207 JoystickDisconnected,
208 TouchBegan,
209 TouchMoved,
210 TouchEnded,
211 SensorChanged,
212
213 Count
214 };
215
217 // Member data
219 EventType type;
220
221 union
222 {
223 SizeEvent size;
224 KeyEvent key;
225 TextEvent text;
226 MouseMoveEvent mouseMove;
227 MouseButtonEvent mouseButton;
228 MouseWheelEvent mouseWheel;
229 MouseWheelScrollEvent mouseWheelScroll;
230 JoystickMoveEvent joystickMove;
231 JoystickButtonEvent joystickButton;
232 JoystickConnectEvent joystickConnect;
233 TouchEvent touch;
234 SensorEvent sensor;
235 };
236 };
237
238 } // namespace sf
239
240
241 #endif // SFML_EVENT_HPP
242
243
sf::Event::KeyEvent::code
Keyboard::Key code
Code of the key that has been pressed.
Definition: Event.hpp:64
sf::Event::MouseWheelScrollEvent::delta
float delta
Wheel offset (positive is up/left, negative is down/right). High-precision mice may use non-integral ...
Definition: Event.hpp:123
sf::Event::JoystickButtonPressed
A joystick button was pressed (data in event.joystickButton)
Definition: Event.hpp:203
sf::Event::JoystickDisconnected
A joystick was disconnected (data in event.joystickConnect)
Definition: Event.hpp:207
sf::Event::MouseWheelEvent::y
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:113
sf::Event::LostFocus
The window lost the focus (no data)
Definition: Event.hpp:191
sf::Event::MouseButtonEvent::x
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:98
sf::Event::JoystickButtonEvent
Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased) ...
Definition: Event.hpp:154
sf::Event::MouseMoved
The mouse cursor moved (data in event.mouseMove)
Definition: Event.hpp:200
sf::Event::Count
Keep last – the total number of event types.
Definition: Event.hpp:213
sf::Event::KeyEvent
Keyboard event parameters (KeyPressed, KeyReleased)
Definition: Event.hpp:62
sf::Event::JoystickMoveEvent::joystickId
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Definition: Event.hpp:144
sf::Event::JoystickConnected
A joystick was connected (data in event.joystickConnect)
Definition: Event.hpp:206
sf::Event::TouchEnded
A touch event ended (data in event.touch)
Definition: Event.hpp:210
sf::Event::MouseMoveEvent::y
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:87
sf::Event::MouseMoveEvent
Mouse move event parameters (MouseMoved)
Definition: Event.hpp:84
sf::Event::TextEntered
A character was entered (data in event.text)
Definition: Event.hpp:193
sf::Event::TouchEvent::x
int x
X position of the touch, relative to the left of the owner window.
Definition: Event.hpp:167
sf::Event::KeyEvent::alt
bool alt
Is the Alt key pressed?
Definition: Event.hpp:65
sf::Event::SizeEvent::height
unsigned int height
New height, in pixels.
Definition: Event.hpp:55
sf::Event::key
KeyEvent key
Key event parameters (Event::KeyPressed, Event::KeyReleased)
Definition: Event.hpp:224
sf::Event::GainedFocus
The window gained the focus (no data)
Definition: Event.hpp:192
sf::Event::SensorEvent::y
float y
Current value of the sensor on Y axis.
Definition: Event.hpp:179
sf::Event::SensorEvent
Sensor event parameters (SensorChanged)
Definition: Event.hpp:175
sf::Event::sensor
SensorEvent sensor
Sensor event parameters (Event::SensorChanged)
Definition: Event.hpp:234
sf::Event::TouchBegan
A touch event began (data in event.touch)
Definition: Event.hpp:208
sf::Event::text
TextEvent text
Text event parameters (Event::TextEntered)
Definition: Event.hpp:225
sf::Event::touch
TouchEvent touch
Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded) ...
Definition: Event.hpp:233
sf::Joystick::Axis
Axis
Axes supported by SFML joysticks.
Definition: Joystick.hpp:60
sf::Sensor::Type
Type
Sensor type.
Definition: Sensor.hpp:50
sf::Event::KeyReleased
A key was released (data in event.key)
Definition: Event.hpp:195
sf::Event::Resized
The window was resized (data in event.size)
Definition: Event.hpp:190
sf::Event::SizeEvent::width
unsigned int width
New width, in pixels.
Definition: Event.hpp:54
sf::Event::Closed
The window requested to be closed (no data)
Definition: Event.hpp:189
sf::Event::mouseButton
MouseButtonEvent mouseButton
Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased) ...
Definition: Event.hpp:227
sf::Event::MouseLeft
The mouse cursor left the area of the window (no data)
Definition: Event.hpp:202
sf::Event::MouseWheelEvent::delta
int delta
Number of ticks the wheel has moved (positive is up, negative is down)
Definition: Event.hpp:111
sf::Event::TouchEvent
Touch events parameters (TouchBegan, TouchMoved, TouchEnded)
Definition: Event.hpp:164
sf::Event::MouseWheelScrolled
The mouse wheel was scrolled (data in event.mouseWheelScroll)
Definition: Event.hpp:197
sf::Event::MouseButtonPressed
A mouse button was pressed (data in event.mouseButton)
Definition: Event.hpp:198
sf::Event::MouseWheelScrollEvent::x
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:124
sf::Event::MouseWheelMoved
The mouse wheel was scrolled (data in event.mouseWheel) (deprecated)
Definition: Event.hpp:196
sf::Event::JoystickMoveEvent
Joystick axis move event parameters (JoystickMoved)
Definition: Event.hpp:142
sf::Event::joystickMove
JoystickMoveEvent joystickMove
Joystick move event parameters (Event::JoystickMoved)
Definition: Event.hpp:230
sf::Mouse::Wheel
Wheel
Mouse wheels.
Definition: Mouse.hpp:66
sf::Event::MouseWheelEvent
Mouse wheel events parameters (MouseWheelMoved)
Definition: Event.hpp:109
sf::Event::JoystickMoveEvent::axis
Joystick::Axis axis
Axis on which the joystick moved.
Definition: Event.hpp:145
sf::Keyboard::Key
Key
Key codes.
Definition: Keyboard.hpp:48
sf::Event::TouchEvent::y
int y
Y position of the touch, relative to the top of the owner window.
Definition: Event.hpp:168
sf::Event::MouseWheelScrollEvent::wheel
Mouse::Wheel wheel
Which wheel (for mice with multiple ones)
Definition: Event.hpp:122
sf::Event::MouseButtonEvent
Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased)
Definition: Event.hpp:95
sf::Event::KeyEvent::shift
bool shift
Is the Shift key pressed?
Definition: Event.hpp:67
sf::Event
Defines a system event and its parameters.
Definition: Event.hpp:44
sf::Mouse::Button
Button
Mouse buttons.
Definition: Mouse.hpp:51
sf::Event::TextEvent::unicode
Uint32 unicode
UTF-32 Unicode value of the character.
Definition: Event.hpp:77
sf::Event::joystickConnect
JoystickConnectEvent joystickConnect
Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected) ...
Definition: Event.hpp:232
sf::Event::mouseWheel
MouseWheelEvent mouseWheel
Mouse wheel event parameters (Event::MouseWheelMoved) (deprecated)
Definition: Event.hpp:228
sf::Event::MouseEntered
The mouse cursor entered the area of the window (no data)
Definition: Event.hpp:201
sf::Event::KeyPressed
A key was pressed (data in event.key)
Definition: Event.hpp:194
sf::Event::mouseWheelScroll
MouseWheelScrollEvent mouseWheelScroll
Mouse wheel event parameters (Event::MouseWheelScrolled)
Definition: Event.hpp:229
sf::Event::MouseButtonEvent::button
Mouse::Button button
Code of the button that has been pressed.
Definition: Event.hpp:97
sf::Event::KeyEvent::system
bool system
Is the System key pressed?
Definition: Event.hpp:68
sf::Event::MouseWheelEvent::x
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:112
sf::Event::type
EventType type
Type of the event.
Definition: Event.hpp:219
sf::Event::MouseButtonEvent::y
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:99
sf::Event::KeyEvent::control
bool control
Is the Control key pressed?
Definition: Event.hpp:66
sf::Event::MouseButtonReleased
A mouse button was released (data in event.mouseButton)
Definition: Event.hpp:199
sf::Event::JoystickConnectEvent
Joystick connection events parameters (JoystickConnected, JoystickDisconnected)
Definition: Event.hpp:133
sf
Definition: AlResource.hpp:34
sf::Event::mouseMove
MouseMoveEvent mouseMove
Mouse move event parameters (Event::MouseMoved)
Definition: Event.hpp:226
sf::Event::JoystickButtonEvent::joystickId
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Definition: Event.hpp:156
sf::Event::JoystickMoved
The joystick moved along an axis (data in event.joystickMove)
Definition: Event.hpp:205
sf::Event::TouchEvent::finger
unsigned int finger
Index of the finger in case of multi-touch events.
Definition: Event.hpp:166
sf::Event::JoystickButtonReleased
A joystick button was released (data in event.joystickButton)
Definition: Event.hpp:204
sf::Event::JoystickConnectEvent::joystickId
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Definition: Event.hpp:135
sf::Event::MouseMoveEvent::x
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:86
sf::Event::TextEvent
Text event parameters (TextEntered)
Definition: Event.hpp:75
sf::Event::joystickButton
JoystickButtonEvent joystickButton
Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased) ...
Definition: Event.hpp:231
sf::Event::SensorEvent::x
float x
Current value of the sensor on X axis.
Definition: Event.hpp:178
sf::Event::JoystickMoveEvent::position
float position
New position on the axis (in range [-100 .. 100])
Definition: Event.hpp:146
sf::Event::TouchMoved
A touch moved (data in event.touch)
Definition: Event.hpp:209
sf::Event::MouseWheelScrollEvent::y
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:125
sf::Event::SensorChanged
A sensor value changed (data in event.sensor)
Definition: Event.hpp:211
sf::Event::SensorEvent::type
Sensor::Type type
Type of the sensor.
Definition: Event.hpp:177
sf::Event::size
SizeEvent size
Size event parameters (Event::Resized)
Definition: Event.hpp:223
sf::Event::SizeEvent
Size events parameters (Resized)
Definition: Event.hpp:52
sf::Event::MouseWheelScrollEvent
Mouse wheel events parameters (MouseWheelScrolled)
Definition: Event.hpp:120
sf::Event::JoystickButtonEvent::button
unsigned int button
Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1]) ...
Definition: Event.hpp:157
sf::Event::SensorEvent::z
float z
Current value of the sensor on Z axis.
Definition: Event.hpp:180
sf::Event::EventType
EventType
Enumeration of the different types of events.
Definition: Event.hpp:187