Getting position of mouseclick from signal
« on: 16 September 2018, 01:38:10 »
Hi everybody.
I have a canvas that the user can click. When they do, I need to find where on the canvas they clicked.
I understand that the "MousePressed" signal comes with a SignalVector2f that gives the mouse position relative to the widget, but I can't find any documentation on how to access or use that data.
Does anybody have any hints?

Thanks

*

texus

  • *****
  • 1279
    • View Profile
    • Texus's Blog
Re: Getting position of mouseclick from signal
« Reply #1 on: 16 September 2018, 10:43:26 »
The exact parameters are badly documented (or not at all if you consider that it doesn't mention the parameter type anywhere). For a SignalVector2f, the parameter type is just sf::Vector2f, so a callback function would look like this:
void canvasClicked(sf::Vector2f mousePos) // mousePos is relative to canvas position
{
}

canvas->connect("MousePressed", canvasClicked);