Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mouse Button retrive information  (Read 1322 times)

0 Members and 1 Guest are viewing this topic.

IHaveSomeQuestions

  • Newbie
  • *
  • Posts: 6
    • View Profile
Mouse Button retrive information
« 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) || ...)  {
   ...
}

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Mouse Button retrive information
« Reply #1 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.
}
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything