3// SFML - Simple and Fast Multimedia Library 4// Copyright (C) 2007-2025 Laurent Gomila (laurent@sfml-dev.org) 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. 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: 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. 18// 2. Altered source versions must be plainly marked as such, 19// and must not be misrepresented as being the original software. 21// 3. This notice may not be removed or altered from any source distribution. 306template <
typename TEventSubtype>
307Event(
const TEventSubtype& eventSubtype);
317template <
typename TEventSubtype>
318 [[nodiscard]]
boolis()
const;
328template <
typename TEventSubtype>
329 [[nodiscard]]
const TEventSubtype*
getIf()
const;
339template <
typename Visitor>
340decltype(
auto)
visit(Visitor&& visitor)
const;
374template <
typename T,
typename... Ts>
375 [[nodiscard]]
staticconstexprbool isInParameterPack(
const std::variant<Ts...>*)
377return std::disjunction_v<std::is_same<T, Ts>...>;
381staticconstexprbool isEventSubtype = isInParameterPack<T>(
decltype (&m_data)(
nullptr));
385template <
typename Handler,
typename... Ts>
386 [[nodiscard]]
staticconstexprbool isInvocableWithEventSubtype(
const std::variant<Ts...>*)
388return std::disjunction_v<std::is_invocable<Handler&, Ts&>...>;
391template <
typename Handler>
392staticconstexprbool isEventHandler = isInvocableWithEventSubtype<Handler>(
decltype (&m_data)(
nullptr));
397#include <SFML/Window/Event.inl> const TEventSubtype * getIf() const
Attempt to get specified event subtype.
bool is() const
Check current event subtype.
Event(const TEventSubtype &eventSubtype)
Construct from a given sf::Event subtype.
decltype(auto) visit(Visitor &&visitor) const
Apply a visitor to the event.
Axis
Axes supported by SFML joysticks.
Vector3< float > Vector3f
Vector2< unsigned int > Vector2u
Gained focus event subtype.
Lost focus event subtype.
Joystick button pressed event subtype.
unsigned int button
Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick button released event subtype.
unsigned int button
Index of the button that has been released (in range [0 .. Joystick::ButtonCount - 1])
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick connected event subtype.
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick disconnected event subtype.
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick axis move event subtype.
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick::Axis axis
Axis on which the joystick moved.
float position
New position on the axis (in range [-100 .. 100])
Key pressed event subtype.
bool system
Is the System key pressed?
bool control
Is the Control key pressed?
bool shift
Is the Shift key pressed?
bool alt
Is the Alt key pressed?
Keyboard::Key code
Code of the key that has been pressed.
Keyboard::Scancode scancode
Physical code of the key that has been pressed.
Key released event subtype.
bool alt
Is the Alt key pressed?
bool control
Is the Control key pressed?
bool shift
Is the Shift key pressed?
bool system
Is the System key pressed?
Keyboard::Key code
Code of the key that has been released.
Keyboard::Scancode scancode
Physical code of the key that has been released.
Mouse button pressed event subtype.
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
Mouse::Button button
Code of the button that has been pressed.
Mouse button released event subtype.
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
Mouse::Button button
Code of the button that has been released.
Mouse entered event subtype.
Mouse left event subtype.
Mouse move raw event subtype.
Vector2i delta
Delta movement of the mouse since the last event.
Mouse move event subtype.
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
Mouse wheel scrolled event subtype.
Mouse::Wheel wheel
Which wheel (for mice with multiple ones)
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
float delta
Wheel offset (positive is up/left, negative is down/right). High-precision mice may use non-integral ...
Vector2u size
New size, in pixels.
Sensor::Type type
Type of the sensor.
Vector3f value
Current value of the sensor on the X, Y, and Z axes.
char32_t unicode
UTF-32 Unicode value of the character.
Touch began event subtype.
Vector2i position
Start position of the touch, relative to the top left of the owner window.
unsigned int finger
Index of the finger in case of multi-touch events.
Touch ended event subtype.
Vector2i position
Final position of the touch, relative to the top left of the owner window.
unsigned int finger
Index of the finger in case of multi-touch events.
Touch moved event subtype.
Vector2i position
Current position of the touch, relative to the top left of the owner window.
unsigned int finger
Index of the finger in case of multi-touch events.