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

Author Topic: Possible bug with IsMouseButtonDown(sf::Mouse::Left)  (Read 1845 times)

0 Members and 1 Guest are viewing this topic.

ThatSomeMess

  • Newbie
  • *
  • Posts: 1
    • View Profile
Possible bug with IsMouseButtonDown(sf::Mouse::Left)
« on: March 11, 2012, 12:03:49 am »
Hi,

I've written a small test program which collects events and draws to the screen only when the left mouse button is down.

The problem occurs with the following sequence of events:

I hold down the left mouse button to start drawing.
I move the mouse cursor outside of the window area.
I release the button.
I move the cursor back into the window area.

Now the screen is still being drawn to even though the mouse button is no longer down.

Code:

Code: [Select]
       if (input.IsMouseButtonDown(sf::Mouse::Left))
        {
            // register action for undo, and save prompt

            while (input.IsMouseButtonDown(sf::Mouse::Left))
            {
                eInst.editActionDraw();

                /* get and discard events */

                win->Clear();
                drawTiles();
                drawUI();
                win->Display();
            }
        }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Possible bug with IsMouseButtonDown(sf::Mouse::Left)
« Reply #1 on: March 11, 2012, 09:26:01 am »
It's a bad side effect of how sf::Input is implemented: it collects the window events instead of directly asking the OS. Therefore, anything that happens outside the window is not taken in account.

It's already fixed in SFML 2.
Laurent Gomila - SFML developer

 

anything