Loading...
Searching...
No Matches
Event.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2013 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>
34#include <SFML/Window/Mouse.hpp>
35
36
37namespace sf
38{
43class Event
44{
45public :
46
51 struct SizeEvent
52 {
53 unsigned int width;
54 unsigned int height;
55 };
56
61 struct KeyEvent
62 {
64 bool alt;
65 bool control;
66 bool shift;
67 bool system;
68 };
69
74 struct TextEvent
75 {
77 };
78
84 {
85 int x;
86 int y;
87 };
88
95 {
97 int x;
98 int y;
99 };
100
106 {
107 int delta;
108 int x;
109 int y;
110 };
111
118 {
119 unsigned int joystickId;
120 };
121
127 {
128 unsigned int joystickId;
130 float position;
131 };
132
139 {
140 unsigned int joystickId;
141 unsigned int button;
142 };
143
171
173 // Member data
176
177 union
178 {
188 };
189};
190
191} // namespace sf
192
193
194#endif // SFML_EVENT_HPP
195
196
Defines a system event and its parameters.
Definition Event.hpp:44
TextEvent text
Text event parameters (Event::TextEntered).
Definition Event.hpp:181
MouseButtonEvent mouseButton
Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased).
Definition Event.hpp:183
JoystickButtonEvent joystickButton
Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased).
Definition Event.hpp:186
KeyEvent key
Key event parameters (Event::KeyPressed, Event::KeyReleased).
Definition Event.hpp:180
MouseMoveEvent mouseMove
Mouse move event parameters (Event::MouseMoved).
Definition Event.hpp:182
SizeEvent size
Size event parameters (Event::Resized).
Definition Event.hpp:179
MouseWheelEvent mouseWheel
Mouse wheel event parameters (Event::MouseWheelMoved).
Definition Event.hpp:184
JoystickConnectEvent joystickConnect
Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected).
Definition Event.hpp:187
JoystickMoveEvent joystickMove
Joystick move event parameters (Event::JoystickMoved).
Definition Event.hpp:185
EventType type
Type of the event.
Definition Event.hpp:175
EventType
Enumeration of the different types of events.
Definition Event.hpp:149
@ JoystickButtonReleased
A joystick button was released (data in event.joystickButton).
Definition Event.hpp:164
@ Closed
The window requested to be closed (no data).
Definition Event.hpp:150
@ JoystickMoved
The joystick moved along an axis (data in event.joystickMove).
Definition Event.hpp:165
@ MouseMoved
The mouse cursor moved (data in event.mouseMove).
Definition Event.hpp:160
@ MouseEntered
The mouse cursor entered the area of the window (no data).
Definition Event.hpp:161
@ MouseButtonPressed
A mouse button was pressed (data in event.mouseButton).
Definition Event.hpp:158
@ MouseWheelMoved
The mouse wheel was scrolled (data in event.mouseWheel).
Definition Event.hpp:157
@ Resized
The window was resized (data in event.size).
Definition Event.hpp:151
@ JoystickButtonPressed
A joystick button was pressed (data in event.joystickButton).
Definition Event.hpp:163
@ TextEntered
A character was entered (data in event.text).
Definition Event.hpp:154
@ GainedFocus
The window gained the focus (no data).
Definition Event.hpp:153
@ MouseButtonReleased
A mouse button was released (data in event.mouseButton).
Definition Event.hpp:159
@ KeyReleased
A key was released (data in event.key).
Definition Event.hpp:156
@ MouseLeft
The mouse cursor left the area of the window (no data).
Definition Event.hpp:162
@ JoystickConnected
A joystick was connected (data in event.joystickConnect).
Definition Event.hpp:166
@ JoystickDisconnected
A joystick was disconnected (data in event.joystickConnect).
Definition Event.hpp:167
@ LostFocus
The window lost the focus (no data).
Definition Event.hpp:152
@ KeyPressed
A key was pressed (data in event.key).
Definition Event.hpp:155
@ Count
Keep last – the total number of event types.
Definition Event.hpp:169
Axis
Axes supported by SFML joysticks.
Definition Joystick.hpp:60
Key
Key codes.
Definition Keyboard.hpp:49
Button
Mouse buttons.
Definition Mouse.hpp:52
unsigned int Uint32
Definition Config.hpp:145
Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased).
Definition Event.hpp:139
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1]).
Definition Event.hpp:140
unsigned int button
Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1]).
Definition Event.hpp:141
Joystick connection events parameters (JoystickConnected, JoystickDisconnected).
Definition Event.hpp:118
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1]).
Definition Event.hpp:119
Joystick axis move event parameters (JoystickMoved).
Definition Event.hpp:127
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1]).
Definition Event.hpp:128
float position
New position on the axis (in range [-100 .. 100]).
Definition Event.hpp:130
Joystick::Axis axis
Axis on which the joystick moved.
Definition Event.hpp:129
Keyboard event parameters (KeyPressed, KeyReleased).
Definition Event.hpp:62
Keyboard::Key code
Code of the key that has been pressed.
Definition Event.hpp:63
bool shift
Is the Shift key pressed?
Definition Event.hpp:66
bool alt
Is the Alt key pressed?
Definition Event.hpp:64
bool control
Is the Control key pressed?
Definition Event.hpp:65
bool system
Is the System key pressed?
Definition Event.hpp:67
Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased).
Definition Event.hpp:95
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition Event.hpp:97
Mouse::Button button
Code of the button that has been pressed.
Definition Event.hpp:96
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition Event.hpp:98
Mouse move event parameters (MouseMoved).
Definition Event.hpp:84
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition Event.hpp:86
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition Event.hpp:85
Mouse wheel events parameters (MouseWheelMoved).
Definition Event.hpp:106
int x
X position of the mouse pointer, relative to the left of the owner window.
Definition Event.hpp:108
int delta
Number of ticks the wheel has moved (positive is up, negative is down).
Definition Event.hpp:107
int y
Y position of the mouse pointer, relative to the top of the owner window.
Definition Event.hpp:109
Size events parameters (Resized).
Definition Event.hpp:52
unsigned int width
New width, in pixels.
Definition Event.hpp:53
unsigned int height
New height, in pixels.
Definition Event.hpp:54
Text event parameters (TextEntered).
Definition Event.hpp:75
Uint32 unicode
UTF-32 unicode value of the character.
Definition Event.hpp:76