Loading...
Searching...
No Matches
MouseEvents.h
Go to the documentation of this file.
1//
2// Created by Dave R. Smith on 3/3/25.
3//
4
5#ifndef MOUSEEVENTS_H
6#define MOUSEEVENTS_H
7
8#pragma once
9
10#include <SFML/Graphics.hpp>
11
12namespace ml
13{
34 {
35 public:
48 template<typename T>
49 static bool isHovered(const T& obj, const sf::RenderWindow& window)
50 {
51 return isHovered(obj.getGlobalBounds(), window);
52 }
53
64 static bool isHovered(const sf::FloatRect& bounds, const sf::RenderWindow& window);
65
78 template<typename T>
79 static bool isClicked(const T& obj, const sf::RenderWindow& window)
80 {
81 return isClicked(obj.getGlobalBounds(), window);
82 }
83
95 static bool isClicked(const sf::FloatRect& bounds, const sf::RenderWindow& window);
96 };
97
98} // namespace ml
99
100#endif // MOUSEEVENTS_H
Static helpers for mouse hit-testing against framework objects.
Definition MouseEvents.h:34
static bool isClicked(const sf::FloatRect &bounds, const sf::RenderWindow &window)
Return true if the left mouse button is held over a rect.
static bool isHovered(const sf::FloatRect &bounds, const sf::RenderWindow &window)
Return true if the mouse is currently over a rect.
static bool isHovered(const T &obj, const sf::RenderWindow &window)
Return true if the mouse is currently over a framework object.
Definition MouseEvents.h:49
static bool isClicked(const T &obj, const sf::RenderWindow &window)
Return true if the left mouse button is held over a framework object.
Definition MouseEvents.h:79
Definition Component.h:18
Rect< float > FloatRect