Hi! I'm wondering if I have for example a SFML window with a image of a start button or something. How can I do so that when I click that button it happens something. I just want to know how to do if I want to click in a special area within the window. In if the mouse wheren't in the special area it shouldn't happen anything. Here is my code to make it clearer what I want to achieve.
#include <iostream>
#include <SFML/Window.hpp>
using namespace std;
int main()
{
sf::Window window;
window.create(sf::VideoMode(640, 480), "Window");
sf::Event event;
window.setKeyRepeatEnabled(false);
while (window.isOpen())
{
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed: window.close(); break;
case sf::Event::MouseMoved:
cout << "X: " << event.mouseMove.x << endl;
cout << "Y: " << event.mouseMove.y << endl;
break;
default: break;
}
if (event.type == sf::Event::MouseMoved)
{
cout << "Mouse Moved";
if (event.type == sf::Event::MouseButtonPressed)
{
cout << "Mouse Button Pressed";
}
}
}
}
return 0;
}