I am testing mouse events in SDL2. I want to print "button" to the console window whenever a mouse button is pressed (right, left and middle button). However, when I move my mouse without pressing any button, the message is also printed. Why is that?
while (!quit)
{
SDL_WaitEvent(&event);
switch (event.type)
{
case SDL_QUIT:
quit = true;
break;
default:
if (event.type = SDL_MOUSEBUTTONDOWN)
{
std::cout << "button\n";
}
break;
}