Defines a system event and its parameters. More...
#include <Event.hpp>
Classes | |
struct | JoyButtonEvent |
Joystick buttons events parameters (JoyButtonPressed, JoyButtonReleased). More... | |
struct | JoyMoveEvent |
Joystick axis move event parameters (JoyMoved). More... | |
struct | KeyEvent |
Keyboard event parameters (KeyPressed, KeyReleased). More... | |
struct | MouseButtonEvent |
Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased). More... | |
struct | MouseMoveEvent |
Mouse move event parameters (MouseMoved). More... | |
struct | MouseWheelEvent |
Mouse wheel events parameters (MouseWheelMoved). More... | |
struct | SizeEvent |
Size events parameters (Resized). More... | |
struct | TextEvent |
Text event parameters (TextEntered). More... | |
Public Types | |
enum | EventType { Closed, Resized, LostFocus, GainedFocus, TextEntered, KeyPressed, KeyReleased, MouseWheelMoved, MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseEntered, MouseLeft, JoyButtonPressed, JoyButtonReleased, JoyMoved, Count } |
Enumeration of the different types of events. More... | |
Public Attributes | |
EventType | Type |
Type of the event. | |
union { | |
KeyEvent Key | |
Key event parameters. | |
TextEvent Text | |
Text event parameters. | |
MouseMoveEvent MouseMove | |
Mouse move event parameters. | |
MouseButtonEvent MouseButton | |
Mouse button event parameters. | |
MouseWheelEvent MouseWheel | |
Mouse wheel event parameters. | |
JoyMoveEvent JoyMove | |
Joystick move event parameters. | |
JoyButtonEvent JoyButton | |
Joystick button event parameters. | |
SizeEvent Size | |
Size event parameters. | |
}; |
Defines a system event and its parameters.
sf::Event holds all the informations about a system event that just happened.
Events are retrieved using the sf::Window::GetEvent function.
A sf::Event instance contains the type of the event (mouse moved, key pressed, window closed, ...) as well as the details about this particular event. Please note that the event parameters are defined in a union, which means that only the member matching the type of the event will be properly filled; all other members will have undefined values and must not be read if the type of the event doesn't match. For example, if you received a KeyPressed event, then you must read the event.Key member, all other members such as event.MouseMove or event.Text will have undefined values.
Usage example:
sf::Event event; while (window.GetEvent(event)) { // Request for closing the window if (event.Type == sf::Event::Closed) window.Close(); // The escape key was pressed if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape)) window.Close(); // The window was resized if (event.Type == sf::Event::Resized) DoSomethingWithTheNewSize(event.Size.Width, event.Size.Height); // etc ... }
Definition at line 201 of file Event.hpp.
enum sf::Event::EventType |
Enumeration of the different types of events.