SFML community forums

Help => Graphics => Topic started by: darekg11 on October 02, 2010, 02:37:39 pm

Title: Detecting is mouse is over String
Post by: darekg11 on October 02, 2010, 02:37:39 pm
Hello, how Can I detect if Mouse is over String?
Which positions return function:
sfString_GetX()
sfString_GetY()
?
I want to do something like:
if position of mouse is in area of string
{
  DrawRentacgle
}
I just don't know excatly how to detect if it's over.
Title: Detecting is mouse is over String
Post by: Finn on October 02, 2010, 03:32:22 pm
Well. This one is C++ but I think it will help you :)
Code: [Select]

bool MouseOver(sf::String &String)//overload with sf::String
{
if ( MouseX > String.GetRect().Left && MouseX < String.GetRect().Right)
{
if ( MouseY > String.GetRect().Top && MouseY < String.GetRect().Bottom)
        return true;
}
else
return false;
}
Title: Detecting is mouse is over String
Post by: darekg11 on October 02, 2010, 03:38:24 pm
Fack, I couldn't find a proper function for like 1hour and I started to write my own from scratch x_x.

Anyway thanks Your function is what I need, damn it.

EDIT: Everything works perfect, BIG THANKS.