Getting position of mouseclick from signal

Started by methinks82, 16 September 2018, 01:38:10

methinks82

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

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:
Code (cpp) Select
void canvasClicked(sf::Vector2f mousePos) // mousePos is relative to canvas position
{
}

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