Documentation of SFML 2.2

Warning: this page refers to an old version of SFML. Click here to switch to the latest version.
Event.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
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  {
65  bool alt;
66  bool control;
67  bool shift;
68  bool system;
69  };
70 
75  struct TextEvent
76  {
77  Uint32 unicode;
78  };
79 
85  {
86  int x;
87  int y;
88  };
89 
96  {
98  int x;
99  int y;
100  };
101 
107  {
108  int delta;
109  int x;
110  int y;
111  };
112 
119  {
120  unsigned int joystickId;
121  };
122 
128  {
129  unsigned int joystickId;
131  float position;
132  };
133 
140  {
141  unsigned int joystickId;
142  unsigned int button;
143  };
144 
149  struct TouchEvent
150  {
151  unsigned int finger;
152  int x;
153  int y;
154  };
155 
160  struct SensorEvent
161  {
163  float x;
164  float y;
165  float z;
166  };
167 
173  {
196 
198  };
199 
201  // Member data
204 
205  union
206  {
218  };
219 };
220 
221 } // namespace sf
222 
223 
224 #endif // SFML_EVENT_HPP
225 
226 
A key was pressed (data in event.key)
Definition: Event.hpp:179
float z
Current value of the sensor on Z axis.
Definition: Event.hpp:165
A key was released (data in event.key)
Definition: Event.hpp:180
The joystick moved along an axis (data in event.joystickMove)
Definition: Event.hpp:189
Joystick connection events parameters (JoystickConnected, JoystickDisconnected)
Definition: Event.hpp:118
The mouse cursor left the area of the window (no data)
Definition: Event.hpp:186
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:98
EventType
Enumeration of the different types of events.
Definition: Event.hpp:172
bool control
Is the Control key pressed?
Definition: Event.hpp:66
Text event parameters (TextEntered)
Definition: Event.hpp:75
The window lost the focus (no data)
Definition: Event.hpp:176
bool system
Is the System key pressed?
Definition: Event.hpp:68
Mouse wheel events parameters (MouseWheelMoved)
Definition: Event.hpp:106
Type
Sensor type.
Definition: Sensor.hpp:50
unsigned int width
New width, in pixels.
Definition: Event.hpp:54
The mouse cursor entered the area of the window (no data)
Definition: Event.hpp:185
A joystick button was pressed (data in event.joystickButton)
Definition: Event.hpp:187
Sensor::Type type
Type of the sensor.
Definition: Event.hpp:162
A sensor value changed (data in event.sensor)
Definition: Event.hpp:195
A mouse button was pressed (data in event.mouseButton)
Definition: Event.hpp:182
A touch event ended (data in event.touch)
Definition: Event.hpp:194
The mouse cursor moved (data in event.mouseMove)
Definition: Event.hpp:184
Definition: Listener.hpp:35
unsigned int height
New height, in pixels.
Definition: Event.hpp:55
The mouse wheel was scrolled (data in event.mouseWheel)
Definition: Event.hpp:181
The window gained the focus (no data)
Definition: Event.hpp:177
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:109
Key
Key codes.
Definition: Keyboard.hpp:48
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition: Event.hpp:86
A touch moved (data in event.touch)
Definition: Event.hpp:193
bool shift
Is the Shift key pressed?
Definition: Event.hpp:67
Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased) ...
Definition: Event.hpp:139
float y
Current value of the sensor on Y axis.
Definition: Event.hpp:164
Defines a system event and its parameters.
Definition: Event.hpp:44
Touch events parameters (TouchBegan, TouchMoved, TouchEnded)
Definition: Event.hpp:149
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Definition: Event.hpp:141
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Definition: Event.hpp:129
Keyboard::Key code
Code of the key that has been pressed.
Definition: Event.hpp:64
Axis
Axes supported by SFML joysticks.
Definition: Joystick.hpp:60
Keyboard event parameters (KeyPressed, KeyReleased)
Definition: Event.hpp:62
int y
Y position of the touch, relative to the top of the owner window.
Definition: Event.hpp:153
Joystick::Axis axis
Axis on which the joystick moved.
Definition: Event.hpp:130
JoystickButtonEvent joystickButton
Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased) ...
Definition: Event.hpp:214
Size events parameters (Resized)
Definition: Event.hpp:52
The window requested to be closed (no data)
Definition: Event.hpp:174
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Definition: Event.hpp:120
Uint32 unicode
UTF-32 Unicode value of the character.
Definition: Event.hpp:77
MouseWheelEvent mouseWheel
Mouse wheel event parameters (Event::MouseWheelMoved)
Definition: Event.hpp:212
Mouse move event parameters (MouseMoved)
Definition: Event.hpp:84
int x
X position of the touch, relative to the left of the owner window.
Definition: Event.hpp:152
A character was entered (data in event.text)
Definition: Event.hpp:178
Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased)
Definition: Event.hpp:95
The window was resized (data in event.size)
Definition: Event.hpp:175
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:99
TextEvent text
Text event parameters (Event::TextEntered)
Definition: Event.hpp:209
MouseMoveEvent mouseMove
Mouse move event parameters (Event::MouseMoved)
Definition: Event.hpp:210
MouseButtonEvent mouseButton
Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased) ...
Definition: Event.hpp:211
unsigned int finger
Index of the finger in case of multi-touch events.
Definition: Event.hpp:151
A joystick button was released (data in event.joystickButton)
Definition: Event.hpp:188
Sensor event parameters (SensorChanged)
Definition: Event.hpp:160
JoystickMoveEvent joystickMove
Joystick move event parameters (Event::JoystickMoved)
Definition: Event.hpp:213
float x
Current value of the sensor on X axis.
Definition: Event.hpp:163
float position
New position on the axis (in range [-100 .. 100])
Definition: Event.hpp:131
EventType type
Type of the event.
Definition: Event.hpp:203
SensorEvent sensor
Sensor event parameters (Event::SensorChanged)
Definition: Event.hpp:217
KeyEvent key
Key event parameters (Event::KeyPressed, Event::KeyReleased)
Definition: Event.hpp:208
A mouse button was released (data in event.mouseButton)
Definition: Event.hpp:183
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:110
Button
Mouse buttons.
Definition: Mouse.hpp:51
JoystickConnectEvent joystickConnect
Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected) ...
Definition: Event.hpp:215
A joystick was connected (data in event.joystickConnect)
Definition: Event.hpp:190
TouchEvent touch
Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded) ...
Definition: Event.hpp:216
int delta
Number of ticks the wheel has moved (positive is up, negative is down)
Definition: Event.hpp:108
A touch event began (data in event.touch)
Definition: Event.hpp:192
unsigned int button
Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1]) ...
Definition: Event.hpp:142
A joystick was disconnected (data in event.joystickConnect)
Definition: Event.hpp:191
Mouse::Button button
Code of the button that has been pressed.
Definition: Event.hpp:97
Keep last – the total number of event types.
Definition: Event.hpp:197
SizeEvent size
Size event parameters (Event::Resized)
Definition: Event.hpp:207
bool alt
Is the Alt key pressed?
Definition: Event.hpp:65
Joystick axis move event parameters (JoystickMoved)
Definition: Event.hpp:127
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition: Event.hpp:87