sf::Event Class Reference
[Window module]

Defines a system event and its parameters. More...

#include <Event.hpp>

List of all members.

Classes

struct  JoystickButtonEvent
 Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased). More...
struct  JoystickConnectEvent
 Joystick connection events parameters (JoystickConnected, JoystickDisconnected). More...
struct  JoystickMoveEvent
 Joystick axis move event parameters (JoystickMoved). 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,
  JoystickButtonPressed,
  JoystickButtonReleased,
  JoystickMoved,
  JoystickConnected,
  JoystickDisconnected,
  Count
}
 

Enumeration of the different types of events.

More...

Public Attributes

EventType Type
 Type of the event.
union {
   SizeEvent   Size
 Size event parameters.
   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.
   JoystickMoveEvent   JoystickMove
 Joystick move event parameters.
   JoystickButtonEvent   JoystickButton
 Joystick button event parameters.
   JoystickConnectEvent   JoystickConnect
 Joystick (dis)connect event parameters.
}; 

Detailed Description

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::PollEvent and sf::Window::WaitEvent 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.MouseMove or event.Text will have undefined values.

Usage example:

 sf::Event event;
 while (window.PollEvent(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::Keyboard::Escape))
         window.Close();

     // The window was resized
     if (event.Type == sf::Event::Resized)
         DoSomethingWithTheNewSize(event.Size.Width, event.Size.Height);

     // etc ...
 }

Definition at line 43 of file Event.hpp.


Member Enumeration Documentation

Enumeration of the different types of events.

Enumerator:
Closed 

The window requested to be closed.

Resized 

The window was resized.

LostFocus 

The window lost the focus.

GainedFocus 

The window gained the focus.

TextEntered 

A character was entered.

KeyPressed 

A key was pressed.

KeyReleased 

A key was released.

MouseWheelMoved 

The mouse wheel was scrolled.

MouseButtonPressed 

A mouse button was pressed.

MouseButtonReleased 

A mouse button was released.

MouseMoved 

The mouse cursor moved.

MouseEntered 

The mouse cursor entered the area of the window.

MouseLeft 

The mouse cursor left the area of the window.

JoystickButtonPressed 

A joystick button was pressed.

JoystickButtonReleased 

A joystick button was released.

JoystickMoved 

The joystick moved along an axis.

JoystickConnected 

A joystick was connected.

JoystickDisconnected 

A joystick was disconnected.

Count 

Keep last -- the total number of event types.

Definition at line 148 of file Event.hpp.


Member Data Documentation

Joystick button event parameters.

Definition at line 186 of file Event.hpp.

Joystick (dis)connect event parameters.

Definition at line 187 of file Event.hpp.

Joystick move event parameters.

Definition at line 185 of file Event.hpp.

Key event parameters.

Definition at line 180 of file Event.hpp.

Mouse button event parameters.

Definition at line 183 of file Event.hpp.

Mouse move event parameters.

Definition at line 182 of file Event.hpp.

Mouse wheel event parameters.

Definition at line 184 of file Event.hpp.

Size event parameters.

Definition at line 179 of file Event.hpp.

Text event parameters.

Definition at line 181 of file Event.hpp.

Type of the event.

Definition at line 175 of file Event.hpp.


The documentation for this class was generated from the following file: