Documentation de SFML 2.3.1

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
sf::Event Class Reference

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

#include <Event.hpp>

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  MouseWheelScrollEvent
 Mouse wheel events parameters (MouseWheelScrolled) More...
 
struct  SensorEvent
 Sensor event parameters (SensorChanged) More...
 
struct  SizeEvent
 Size events parameters (Resized) More...
 
struct  TextEvent
 Text event parameters (TextEntered) More...
 
struct  TouchEvent
 Touch events parameters (TouchBegan, TouchMoved, TouchEnded) More...
 

Public Types

enum  EventType {
  Closed, Resized, LostFocus, GainedFocus,
  TextEntered, KeyPressed, KeyReleased, MouseWheelMoved,
  MouseWheelScrolled, MouseButtonPressed, MouseButtonReleased, MouseMoved,
  MouseEntered, MouseLeft, JoystickButtonPressed, JoystickButtonReleased,
  JoystickMoved, JoystickConnected, JoystickDisconnected, TouchBegan,
  TouchMoved, TouchEnded, SensorChanged, Count
}
 Enumeration of the different types of events. More...
 

Public Attributes

EventType type
 Type of the event. More...
 
union {
   SizeEvent   size
 Size event parameters (Event::Resized) More...
 
   KeyEvent   key
 Key event parameters (Event::KeyPressed, Event::KeyReleased) More...
 
   TextEvent   text
 Text event parameters (Event::TextEntered) More...
 
   MouseMoveEvent   mouseMove
 Mouse move event parameters (Event::MouseMoved) More...
 
   MouseButtonEvent   mouseButton
 Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased) More...
 
   MouseWheelEvent   mouseWheel
 Mouse wheel event parameters (Event::MouseWheelMoved) (deprecated) More...
 
   MouseWheelScrollEvent   mouseWheelScroll
 Mouse wheel event parameters (Event::MouseWheelScrolled) More...
 
   JoystickMoveEvent   joystickMove
 Joystick move event parameters (Event::JoystickMoved) More...
 
   JoystickButtonEvent   joystickButton
 Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased) More...
 
   JoystickConnectEvent   joystickConnect
 Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected) More...
 
   TouchEvent   touch
 Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded) More...
 
   SensorEvent   sensor
 Sensor event parameters (Event::SensorChanged) More...
 
}; 
 

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 44 of file Event.hpp.

Member Enumeration Documentation

Enumeration of the different types of events.

Enumerator
Closed 

The window requested to be closed (no data)

Resized 

The window was resized (data in event.size)

LostFocus 

The window lost the focus (no data)

GainedFocus 

The window gained the focus (no data)

TextEntered 

A character was entered (data in event.text)

KeyPressed 

A key was pressed (data in event.key)

KeyReleased 

A key was released (data in event.key)

MouseWheelMoved 

The mouse wheel was scrolled (data in event.mouseWheel) (deprecated)

MouseWheelScrolled 

The mouse wheel was scrolled (data in event.mouseWheelScroll)

MouseButtonPressed 

A mouse button was pressed (data in event.mouseButton)

MouseButtonReleased 

A mouse button was released (data in event.mouseButton)

MouseMoved 

The mouse cursor moved (data in event.mouseMove)

MouseEntered 

The mouse cursor entered the area of the window (no data)

MouseLeft 

The mouse cursor left the area of the window (no data)

JoystickButtonPressed 

A joystick button was pressed (data in event.joystickButton)

JoystickButtonReleased 

A joystick button was released (data in event.joystickButton)

JoystickMoved 

The joystick moved along an axis (data in event.joystickMove)

JoystickConnected 

A joystick was connected (data in event.joystickConnect)

JoystickDisconnected 

A joystick was disconnected (data in event.joystickConnect)

TouchBegan 

A touch event began (data in event.touch)

TouchMoved 

A touch moved (data in event.touch)

TouchEnded 

A touch event ended (data in event.touch)

SensorChanged 

A sensor value changed (data in event.sensor)

Count 

Keep last – the total number of event types.

Definition at line 187 of file Event.hpp.

Member Data Documentation

JoystickButtonEvent sf::Event::joystickButton

Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)

Definition at line 231 of file Event.hpp.

JoystickConnectEvent sf::Event::joystickConnect

Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected)

Definition at line 232 of file Event.hpp.

JoystickMoveEvent sf::Event::joystickMove

Joystick move event parameters (Event::JoystickMoved)

Definition at line 230 of file Event.hpp.

KeyEvent sf::Event::key

Key event parameters (Event::KeyPressed, Event::KeyReleased)

Definition at line 224 of file Event.hpp.

MouseButtonEvent sf::Event::mouseButton

Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)

Definition at line 227 of file Event.hpp.

MouseMoveEvent sf::Event::mouseMove

Mouse move event parameters (Event::MouseMoved)

Definition at line 226 of file Event.hpp.

MouseWheelEvent sf::Event::mouseWheel

Mouse wheel event parameters (Event::MouseWheelMoved) (deprecated)

Definition at line 228 of file Event.hpp.

MouseWheelScrollEvent sf::Event::mouseWheelScroll

Mouse wheel event parameters (Event::MouseWheelScrolled)

Definition at line 229 of file Event.hpp.

SensorEvent sf::Event::sensor

Sensor event parameters (Event::SensorChanged)

Definition at line 234 of file Event.hpp.

SizeEvent sf::Event::size

Size event parameters (Event::Resized)

Definition at line 223 of file Event.hpp.

TextEvent sf::Event::text

Text event parameters (Event::TextEntered)

Definition at line 225 of file Event.hpp.

TouchEvent sf::Event::touch

Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded)

Definition at line 233 of file Event.hpp.

EventType sf::Event::type

Type of the event.

Definition at line 219 of file Event.hpp.


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