Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Defines a system event and its parameters. More...
#include <SFML/Window/Event.hpp>
Classes | |
struct | Closed |
Closed event subtype. More... | |
struct | FocusGained |
Gained focus event subtype. More... | |
struct | FocusLost |
Lost focus event subtype. More... | |
struct | JoystickButtonPressed |
Joystick button pressed event subtype. More... | |
struct | JoystickButtonReleased |
Joystick button released event subtype. More... | |
struct | JoystickConnected |
Joystick connected event subtype. More... | |
struct | JoystickDisconnected |
Joystick disconnected event subtype. More... | |
struct | JoystickMoved |
Joystick axis move event subtype. More... | |
struct | KeyPressed |
Key pressed event subtype. More... | |
struct | KeyReleased |
Key released event subtype. More... | |
struct | MouseButtonPressed |
Mouse button pressed event subtype. More... | |
struct | MouseButtonReleased |
Mouse button released event subtype. More... | |
struct | MouseEntered |
Mouse entered event subtype. More... | |
struct | MouseLeft |
Mouse left event subtype. More... | |
struct | MouseMoved |
Mouse move event subtype. More... | |
struct | MouseMovedRaw |
Mouse move raw event subtype. More... | |
struct | MouseWheelScrolled |
Mouse wheel scrolled event subtype. More... | |
struct | Resized |
Resized event subtype. More... | |
struct | SensorChanged |
Sensor event subtype. More... | |
struct | TextEntered |
Text event subtype. More... | |
struct | TouchBegan |
Touch began event subtype. More... | |
struct | TouchEnded |
Touch ended event subtype. More... | |
struct | TouchMoved |
Touch moved event subtype. More... |
Public Member Functions | |
template<typename TEventSubtype> | |
Event (const TEventSubtype &eventSubtype) | |
Construct from a given sf::Event subtype. | |
template<typename TEventSubtype> | |
bool | is () const |
Check current event subtype. | |
template<typename TEventSubtype> | |
const TEventSubtype * | getIf () const |
Attempt to get specified event subtype. | |
template<typename T> | |
decltype(auto) | visit (T &&visitor) const |
Apply a visitor to the event. |
Defines a system event and its parameters.
sf::Event holds all the information about a system event that just happened.
Events are retrieved using the sf::Window::pollEvent and sf::Window::waitEvent functions.
A sf::Event instance contains the subtype of the event (mouse moved, key pressed, window closed, ...) as well as the details about this particular event. Each event corresponds to a different subtype struct which contains the data required to process that event.
Event subtypes are event types belonging to sf::Event, such as sf::Event::Closed or sf::Event::MouseMoved.
The way to access the current active event subtype is via sf::Event::getIf. This member function returns the address of the event subtype struct if the event subtype matches the active event, otherwise it returns nullptr.
sf::Event::is is used to check the active event subtype without actually reading any of the corresponding event data.
sf::Event::Event | ( | const TEventSubtype & | eventSubtype | ) |
|
nodiscard |
Attempt to get specified event subtype.
`TEventSubtype` | Type of the desired event subtype |
|
nodiscard |
Check current event subtype.
`TEventSubtype` | Type of the event subtype to check against |
decltype(auto) sf::Event::visit | ( | T && | visitor | ) | const |
Apply a visitor to the event.
visitor | The visitor to apply |