Hello. I need to check if both lmb and rmb is pressed. How can i do that?
if (event.type == sf::Event::MouseButtonPressed)
{
if (event.mouseButton.button == sf::Mouse::Left && event.mouseButton.button == sf::Mouse::Right)
std::cout << "LMB+RMB\n";
else if (event.mouseButton.button == sf::Mouse::Left)
std::cout << "LMB\n";
else if (event.mouseButton.button == sf::Mouse::Right)
std::cout << "RMB\n";
}
That code I have now and it is obvious that not work, but how to do that properly?
Thank you! :)
So if anyone will have similar problem here's the code:
if (event.type == sf::Event::MouseButtonPressed)
{
bool left, right;
left = right = false;
if (mouse.isButtonPressed(sf::Mouse::Left))
left = true;
if (mouse.isButtonPressed(sf::Mouse::Right))
right = true;
if (left && right)
std::cout << "LMB+RMB\n";
else if (left)
std::cout << "LMB\n";
else if (right)
std::cout << "RMB\n";
}