abstract struct SF::Event
- SF::Event
- Struct
- Value
- Object
Overview
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.poll_event
and SF::Window.wait_event
functions.
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.mouse_move
or event.text will have undefined values.
Usage example:
while (event = window.poll_event)
case event
when SF::Event::Closed # Request for closing the window
window.close
when SF::Event::KeyPressed # The escape key was pressed
if event.code == SF::Keyboard::Escape
window.close
end
when SF::Event::Resized # The window was resized
do_something(event.width, event.height)
# etc ...
end
end
Direct Known Subclasses
- SF::Event::Closed
- SF::Event::GainedFocus
- SF::Event::JoystickButtonEvent
- SF::Event::JoystickConnectEvent
- SF::Event::JoystickMoveEvent
- SF::Event::KeyEvent
- SF::Event::LostFocus
- SF::Event::MouseButtonEvent
- SF::Event::MouseEntered
- SF::Event::MouseLeft
- SF::Event::MouseMoveEvent
- SF::Event::MouseWheelEvent
- SF::Event::MouseWheelScrollEvent
- SF::Event::SensorEvent
- SF::Event::SizeEvent
- SF::Event::TextEvent
- SF::Event::TouchEvent