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

Author Topic: Mouse Button Pressed and then Moved  (Read 1124 times)

0 Members and 2 Guests are viewing this topic.

khasanovasad

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Mouse Button Pressed and then Moved
« on: June 16, 2020, 01:53:14 pm »
Hi there.

I want my program to detect the following event: Mouse Button Pressed + Mouse Moved

I tried this way:
case sf::Event::MouseMoved:
    if (sf::Mouse::isButtonPressed) {
        DoStuff();
    }
    break;
 

But this does not seem to be the thing I want. Any help would be appreciated. Thanks in advance.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Mouse Button Pressed and then Moved
« Reply #1 on: June 16, 2020, 02:07:28 pm »
You could track the mouse button state in a separate variable, so when you get a mouse moved event, you can check whether the mouse button is pressed or not.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/