Static helpers for mouse hit-testing against framework objects. More...
#include <MouseEvents.h>
Static Public Member Functions | |
| static bool | isClicked (const sf::FloatRect &bounds, const sf::RenderWindow &window) |
Return true if the left mouse button is held over a rect. | |
| template<typename T> | |
| static bool | isClicked (const T &obj, const sf::RenderWindow &window) |
Return true if the left mouse button is held over a framework object. | |
| static bool | isHovered (const sf::FloatRect &bounds, const sf::RenderWindow &window) |
Return true if the mouse is currently over a rect. | |
| template<typename T> | |
| static bool | isHovered (const T &obj, const sf::RenderWindow &window) |
Return true if the mouse is currently over a framework object. | |
Static helpers for mouse hit-testing against framework objects.
MouseEvents provides the low-level spatial queries that UIManager uses each frame to determine which component the mouse is hovering over or clicking on. Each method is overloaded to accept either a framework object (queried via getGlobalBounds()) or a raw sf::FloatRect.
Both isHovered and isClicked convert the current mouse position from screen space to world space before testing, so they work correctly with any view transform.
Subscribable event callbacks (onClick, onHover) which are fired automatically by UIManager.Definition at line 33 of file MouseEvents.h.
|
static |
Return true if the left mouse button is held over a rect.
Combines sf::Mouse::isButtonPressed(Left) with a hover test against bounds.
| bounds | The rectangle to test in world coordinates. |
| Window module | The render window providing the view transform. |
true if the left button is down and the mouse is inside bounds.
|
inlinestatic |
Return true if the left mouse button is held over a framework object.
Delegates to isClicked(obj.getGlobalBounds(), window).
| T | Any type with a getGlobalBounds() method returning sf::FloatRect. |
| obj | The object to test. |
| Window module | The render window used to map mouse coordinates. |
true if the left button is down and the mouse is inside obj's bounds. Definition at line 79 of file MouseEvents.h.
|
static |
Return true if the mouse is currently over a rect.
Maps sf::Mouse::getPosition(window) to world space via the window's current view, then tests containment against bounds.
| bounds | The rectangle to test in world coordinates. |
| Window module | The render window providing the view transform. |
true if the mapped mouse position is inside bounds.
|
inlinestatic |
Return true if the mouse is currently over a framework object.
Delegates to isHovered(obj.getGlobalBounds(), window).
| T | Any type with a getGlobalBounds() method returning sf::FloatRect. |
| obj | The object to test. |
| Window module | The render window used to map mouse coordinates to world space. |
true if the mouse position is inside obj's bounds. Definition at line 49 of file MouseEvents.h.