Consider this minimal example to reproduce the problem:
int main()
{
sf::Window window(sf::VideoMode(800, 600), "test");
sf::Event event;
while (window.isOpen())
{
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::MouseButtonPressed:
switch (event.mouseButton.button)
{
case sf::Mouse::XButton1:
case sf::Mouse::XButton2:
case sf::Mouse::Left:
if (sf::Mouse::isButtonPressed(sf::Mouse::XButton1))
std::cout << "XButton1 pressed" << std::endl;
else if (sf::Mouse::isButtonPressed(sf::Mouse::XButton2))
std::cout << "XButton2 pressed" << std::endl;
else if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
std::cout << "Left button pressed" << std::endl;
else
std::cout << "No button pressed" << std::endl;
break;
default:
break;
}
break;
}
}
}
}
The event for the XButtons is fired, yet sf::Mouse::isButtonPressed returns false; the output is "No button pressed". The problem doesn't occur for the left mouse button, the output is as expected "Left button pressed".
Have I found a bug? Or is there something funny with my mouse? Tested on Ubuntu 20.04.