Captures mouse inputs from the user. More...
#include <Mouse.h>
Public Types | |
enum | Button { Button::Left, Button::Right, Button::Middle, Button::XButton1, Button::XButton2 } |
Mouse buttons. More... | |
enum | Wheel { Wheel::VerticalWheel, Wheel::HorizontalWheel } |
Mouse wheels. More... | |
Public Member Functions | |
int | onButtonUp (Callback< Button, int, int > callback) |
Add an event listener to a mouse button up event. More... | |
int | onButtonUp (Callback< Button > callback) |
Add an event listener to a mouse button up event. More... | |
int | onButtonDown (Callback< Button, int, int > callback) |
Add an event listener to a mouse button up event. More... | |
int | onButtonDown (Callback< Button > callback) |
Add an event listener to a mouse button down event. More... | |
int | onMouseMove (Callback< int, int > callback) |
Add an event listener to a mouse move event. More... | |
int | onWheelScroll (Callback< Wheel, float, int, int > callback) |
Add an event listener to a mouse wheel scroll event. More... | |
bool | unsubscribe (MouseEvent event, int id) |
Remove an event listener from a mouse event. More... | |
void | handleEvent (Event event) |
Handle a system event. More... | |
Static Public Member Functions | |
static bool | isButtonPressed (Button button) |
Check if a mouse button is pressed or not. More... | |
static void | setPosition (const Vector2i &position) |
Set the current position of the mouse in desktop coordinates. More... | |
static Vector2i | getPosition () |
Get the current position of the mouse in desktop coordinates. More... | |
static void | setPosition (const Vector2i &position, const Window &window) |
Set the current position of the mouse in window coordinates. More... | |
static Vector2i | getPosition (const Window &window) |
Get the current position of the mouse in window coordinates. More... | |
Captures mouse inputs from the user.
You usually don't instantiate this class directly, you either use the input manager that is local to a Scene or the global input manager that from the Engine class
|
strong |
|
strong |
|
static |
Get the current position of the mouse in desktop coordinates.
This function returns the global position of the mouse cursor on the desktop.
Get the current position of the mouse in window coordinates.
window | Reference window |
This function returns the current position of the mouse cursor, relative to the given window
void ime::input::Mouse::handleEvent | ( | Event | event | ) |
Handle a system event.
event | Event to be handled |
|
static |
Check if a mouse button is pressed or not.
button | Mouse button to be checked |
This function checks the state of a mouse button in real time, unlike all the other function which are event-based
Add an event listener to a mouse button down event.
callback | The function to be executed when the mouse button is depressed |
The callback is passed the button that was depressed
Add an event listener to a mouse button up event.
callback | The function to be executed when the event a mouse button is released |
The mouse button down event is fired when a mouse button is depressed. The callback is passed the button that was depressed and the coordinates of the mouse cursor when the button was depressed. The mouse cursor coordinates are relative to the game window
Add an event listener to a mouse button up event.
callback | The function to be executed when the mouse button is released |
The mouse button up event is fired when a depressed mouse button is released. The callback is passed the button that was released
Add an event listener to a mouse button up event.
callback | The function to be executed when the mouse button is released |
The mouse button up event is fired when a depressed mouse button is released. The callback is passed the button that was released and the coordinates of the mouse cursor when the button was released. The mouse cursor coordinates are relative to the game window
int ime::input::Mouse::onMouseMove | ( | Callback< int, int > | callback | ) |
Add an event listener to a mouse move event.
callback | Function to execute when the mouse moves |
The callback function will be passed the new position of the mouse cursor
Add an event listener to a mouse wheel scroll event.
callback | Function to be executed when the mouse wheel is scrolled |
The callback is passed the scrolled wheel and the wheel offset (positive is up/left, negative is down/right), and the mouse coordinates relative to the game window
|
static |
Set the current position of the mouse in desktop coordinates.
position | New position of the mouse |
This function sets the global position of the mouse cursor on the desktop
|
static |
Set the current position of the mouse in window coordinates.
position | New position of the mouse |
window | Reference window |
This function sets the current position of the mouse cursor, relative to the given window
bool ime::input::Mouse::unsubscribe | ( | MouseEvent | event, |
int | id | ||
) |
Remove an event listener from a mouse event.
event | The event to remove the event listener from |
id | The id of the event listener |