SDL Utility
Mouse Class Reference

A static class that contains/handles data about mouse position and button states. More...

#include <Mouse.hpp>

Public Types

enum class  Button {
  Left = 1 , Right = 2 , Middle = 3 , XButton1 = 4 ,
  XButton2 = 5
}
 Mouse buttons. More...
 

Static Public Member Functions

static Uint32 GetButtonState ()
 Returns the current mouse button state. More...
 
static bool IsButtonDown (Button button)
 Checks if a specific button is pressed. More...
 
static Vector2i GetPosition ()
 Gets the absolute position of the mouse. More...
 
static Vector2i GetPosition (const RenderWindow &relativeTo)
 Gets current relative position of the mouse. More...
 
static void SetPosition (const Vector2i &position)
 Sets the absolute position of the mouse. More...
 
static void SetPosition (const Vector2i &position, const RenderWindow &relativeTo)
 Sets current relative position of the mouse. More...
 

Detailed Description

A static class that contains/handles data about mouse position and button states.

Member Enumeration Documentation

◆ Button

enum Mouse::Button
strong

Mouse buttons.

Enumerator
Left 
Right 
Middle 
XButton1 
XButton2 

Member Function Documentation

◆ GetButtonState()

static Uint32 Mouse::GetButtonState ( )
static

Returns the current mouse button state.

Returns
A 32-bit mask of the current button state

◆ GetPosition() [1/2]

static Vector2i Mouse::GetPosition ( )
static

Gets the absolute position of the mouse.

Returns
Current mouse position relative to screen

◆ GetPosition() [2/2]

static Vector2i Mouse::GetPosition ( const RenderWindow relativeTo)
static

Gets current relative position of the mouse.

Parameters
[in]relativeToThe window the mouse position should be relative to
Returns
The position of the mouse relative to the top left of the passed window object

◆ IsButtonDown()

static bool Mouse::IsButtonDown ( Button  button)
static

Checks if a specific button is pressed.

Parameters
[in]buttonThe button to check
Returns
True if the button is pressed

◆ SetPosition() [1/2]

static void Mouse::SetPosition ( const Vector2i position)
static

Sets the absolute position of the mouse.

Parameters
[in]positionA 2D vector of the new position

◆ SetPosition() [2/2]

static void Mouse::SetPosition ( const Vector2i position,
const RenderWindow relativeTo 
)
static

Sets current relative position of the mouse.

Parameters
[in]positionA 2D vector of the new position
[in]relativeToThe window the mouse position should be relative to

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