SFML community forums

Help => Window => Topic started by: IHaveSomeQuestions on December 03, 2012, 01:03:05 pm

Title: Mouse Button retrive information
Post by: IHaveSomeQuestions on December 03, 2012, 01:03:05 pm
Hi,

i want to find out if any Mousebutton is Down. Is there a more elegant way of doing it than this?
if(myMouse.isButtonPressed(sf::Mouse::Left) || myMouse.isButtonPressed(sf::Mouse::Right) || ...)  {
   ...
}
Title: Re: Mouse Button retrive information
Post by: eXpl0it3r on December 03, 2012, 01:15:59 pm
i want to find out if any Mousebutton is Down. Is there a more elegant way of doing it than this?
If you want to use sf::Mouse there isn't really an alternative, but you could check for the sf::Event::MouseButtonEvent.

while(window.pollEvent(event)
{
    if(event.type == sf::Event::MouseButtonEvent)
        // A mouse button has been pressed - Do whatever you like.
}