Hello
Usually I like to split my game window (of type RenderWindow) to regions: each region is a RenderTexture which in the end drawn on the main RenderWindow.
By doing this I can split completely the region of the game from the region of the toolbar for instance.
Problem is, when I place a button on the RenderTexture, and I want to check if the button was clicked:
first I'm saving the global coordinates of the mouse click:
const Vector2f mousePos = m_window.mapPixelToCoords({ event.mouseButton.x, event.mouseButton.y });
then I check if the button (of type RectangleShape) contains the position of the click:
if (m_button.getGlobalBounds().contains(mousePos))
And it doesn't work because the m_button.getGlobalBounds() returns the bounds that are relative to the RenderTexture, while m_window.mapPixelToCoords returns coordinates that are relative to the main RenderWindow.
It works only if the button was drawn directly on the main RenderWindow.
Is there a way to convert the mousePos coordinates to be relative to the RenderTexture. Or other way around, to check the GlobalBounds of the button that are relative to the RenderWindow?