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
  # Request for closing the window
  when SF::Event::Closed
    window.close()
  # The escape key was pressed
  when SF::Event::KeyPressed
    if event.code == SF::Keyboard::Escape
      window.close()
    end
  # The window was resized
  when SF::Event::Resized
    do_something(event.width, event.height)
  # etc ...
  end
endDirect 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