Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Classes | Public Attributes | List of all members
gf::Event Struct Reference

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

#include <gf/Event.h>

Classes

struct  GamepadAxisEvent
 Gamepad axis event parameters (EventType::GamepadAxisMoved) More...
 
struct  GamepadButtonEvent
 Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) More...
 
struct  GamepadConnection
 Gamepad connection event parameters (EventType::GamepadConnected) More...
 
struct  GamepadDisconnection
 Gamepad disconnection event parameters (EventType::GamepadDisconnected) More...
 
struct  KeyEvent
 Keyboard event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) More...
 
struct  MouseButtonEvent
 Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) More...
 
struct  MouseCursorEvent
 Mouse cursor move event parameters (EventType::MouseMoved) More...
 
struct  MouseWheelEvent
 Mouse wheel event parameters (EventType::MouseWheelScrolled) More...
 
struct  TextEvent
 Text event parameters (EventType::TextEntered) More...
 

Public Attributes

EventType type
 Type of the event. More...
 
union {
   Vector2u   size
 Size event parameters (EventType::Resized) More...
 
   KeyEvent   key
 Key event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) More...
 
   TextEvent   text
 Text event parameters (EventType::TextEntered) More...
 
   MouseButtonEvent   mouseButton
 Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) More...
 
   MouseCursorEvent   mouseCursor
 Mouse cursor move event parameters (EventType::MouseMoved) More...
 
   MouseWheelEvent   mouseWheel
 Mouse wheel event parameters (EventType::MouseWheelScrolled) More...
 
   GamepadButtonEvent   gamepadButton
 Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) More...
 
   GamepadAxisEvent   gamepadAxis
 Gamepad axis event parameters (EventType::GamepadAxisMoved) More...
 
   GamepadConnection   gamepadConnection
 Gamepad connection event parameters (EventType::GamepadConnected) More...
 
   GamepadDisconnection   gamepadDisconnection
 Gamepad disconnection event parameters (EventType::GamepadDisconnected) More...
 
}; 
 

Detailed Description

Defines a system event and its parameters.

gf::Event holds all the informations about a system event that just happened. Events are retrieved using the gf::Window::pollEvent() and gf::Window::waitEvent() functions.

A gf::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 KeyType::KeyPressed event, then you must read the event.key member, all other members such as event.mouse or event.text will have undefined values.

Usage example:

gf::Event event;
while (window.pollEvent(event)) {
// Request for closing the window
if (event.type == gf::EventType::Closed) {
window.close();
}
// The escape key was pressed
window.close();
}
// The window was resized
if (event.type == gf::EventType::Resized) {
doSomethingWithTheNewSize(event.size.width, event.size.height);
}
// etc ...
}
See also
gf::EventType

Member Data Documentation

union { ... }
GamepadAxisEvent gf::Event::gamepadAxis

Gamepad axis event parameters (EventType::GamepadAxisMoved)

GamepadButtonEvent gf::Event::gamepadButton
GamepadConnection gf::Event::gamepadConnection

Gamepad connection event parameters (EventType::GamepadConnected)

GamepadDisconnection gf::Event::gamepadDisconnection

Gamepad disconnection event parameters (EventType::GamepadDisconnected)

KeyEvent gf::Event::key
MouseButtonEvent gf::Event::mouseButton
MouseCursorEvent gf::Event::mouseCursor

Mouse cursor move event parameters (EventType::MouseMoved)

MouseWheelEvent gf::Event::mouseWheel

Mouse wheel event parameters (EventType::MouseWheelScrolled)

Vector2u gf::Event::size

Size event parameters (EventType::Resized)

TextEvent gf::Event::text

Text event parameters (EventType::TextEntered)

EventType gf::Event::type

Type of the event.