Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Detecting is mouse is over String  (Read 1790 times)

0 Members and 1 Guest are viewing this topic.

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Detecting is mouse is over String
« 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.

Finn

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
Detecting is mouse is over String
« Reply #1 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;
}

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Detecting is mouse is over String
« Reply #2 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.