sf::Event Class Reference

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

#include <Event.hpp>

List of all members.

Classes

struct  JoyButtonEvent
 Joystick buttons events parameters (JoyButtonPressed, JoyButtonReleased). More...
struct  JoyMoveEvent
 Joystick axis move event parameters (JoyMoved). 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,
  JoyButtonPressed,
  JoyButtonReleased,
  JoyMoved,
  Count
}
 

Enumeration of the different types of events.

More...

Public Attributes

EventType Type
 Type of the event.
union {
   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.
   JoyMoveEvent   JoyMove
 Joystick move event parameters.
   JoyButtonEvent   JoyButton
 Joystick button event parameters.
   SizeEvent   Size
 Size 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::GetEvent function.

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.GetEvent(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::Key::Escape))
         window.Close();

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

     // etc ...
 }

Definition at line 201 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.

JoyButtonPressed 

A joystick button was pressed.

JoyButtonReleased 

A joystick button was released.

JoyMoved 

The joystick moved along an axis.

Count 

Keep last -- the total number of event types.

Definition at line 295 of file Event.hpp.


Member Data Documentation

Joystick button event parameters.

Definition at line 330 of file Event.hpp.

Joystick move event parameters.

Definition at line 329 of file Event.hpp.

Key event parameters.

Definition at line 324 of file Event.hpp.

Mouse button event parameters.

Definition at line 327 of file Event.hpp.

Mouse move event parameters.

Definition at line 326 of file Event.hpp.

Mouse wheel event parameters.

Definition at line 328 of file Event.hpp.

Size event parameters.

Definition at line 331 of file Event.hpp.

Text event parameters.

Definition at line 325 of file Event.hpp.

Type of the event.

Definition at line 320 of file Event.hpp.


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