Reacting to User events - JayhawkZombie/EECS581Project GitHub Wiki

User Events


In SFEngine > Source > Headers > Events > UserEvent.h

User events are events generated by the user (or optionally by a system in the engine that is generating events).
Whenever an event is polled, it is wrapped into a UserEvent object, as well as information about that event.
Whenever your class is given an instance of UserEvent, it will be a const-qualified reference.
As such, you will not be able to alter the values as doing so could cause strange behavior to occur.

If you wish to simulate events, you can generate your own.

UserEvent class

This class is the wrapper class for UserEvents. You should receive this object if you are to respond to an event. Normally, you will be informed of an event that you need to respond to except in particular circumstances.

The following UserEventType enums are defined:

MousePress //Pressed on a mouse button    
MouseRelease //Released a mouse button    
MouseMovement //Moved the mouse    
MouseScrollUp //The mouse scroll wheel was scrolled up    
MouseScrollDown //The mouse scroll wheel was scrolled down  
KeyboardPress //A key on the keyboard was pressed  
KeyboardRelease //A key on the keyboard was released  
TextEntered //Used for GUIs. Handles input delay and character repetition for text input    
Unknown //Not sure of the event type    

Methods
bool IsButtonPressed(const sf::Keyboard::Key key) const - determine if a certain key is pressed down
bool IsMouseButtonDown(const sf::Mouse::Button &button) const - determine if a certain mouse button is down

Members
bool MouseButtonWasPressed - determine if a mouse button was pressed during the last frame
bool MouseButtonWasReleased - determine if a mouse button was released last frame
bool KeyWasPressed - determine if a keyboard key was pressed last frame
bool KeyWasReleased - determine if a keyboard key was released last frame
bool KeyRepeat - determine if keyRepeat is enabled (disabled by default)
bool TextWasEntered - determine if text was entered (will only fire if keyRepeat is enabled)
sf::Uint32 TextUnicode - unicode value for the text that was input
sf::Keyboard::Key Key - keyboard enum value for the key that was pressed (sf::Keyboard::Unknown if no key pressed)
sf::Mouse::Button Button - mouse button enum value for the mouse button that was pressed
sf::Vector2i CurrentMousePosition - current position of the mouse (relative to the window)
sf::Vector2i PreviousMousePosition - position of the mouse (relative to the window) during the last frame
UserEventType EventType - the type of event that occurred