You may also want to do a quick check and make sure it isn't a hardware problem with your mouse. Sometimes when mice get worn out the buttons can start to "bounce". Do you have another mouse you can try to reproduce the problem with?
I implemented some check and it seems that it's SFML issue. I added check of actual mouse state from WinAPI. And sometimes SFML report about released key when WinAPI reports that key is still pressed.
Here is an example:
private static class NativeMethods
{
[System.Runtime.InteropServices.DllImport("user32")]
[System.Security.SuppressUnmanagedCodeSecurity]
public static extern short GetAsyncKeyState(int vKey);
public const int VK_LBUTTON = 1;
public const int VK_RBUTTON = 2;
public const int VK_MBUTTON = 4;
}
private void Window_OnMouseButtonReleased(object sender, MouseButtonEventArgs e)
{
if (e.Button == Mouse.Button.Left &&
NativeMethods.GetAsyncKeyState(NativeMethods.VK_LBUTTON)!=0)
{
Logger.Warn("Window_OnMouseButtonReleased: false trigger");
return;
}
}
result:
[ WARN] Window_OnMouseButtonReleased: false trigger
There is need for a long time testing to catch it, because it didn't trigger false event just after app startup.
UPDATE: it seems that I found the reason, I used Mouse.GetPosition in the render loop. I assume that this call may disrupt some internal SFML state and tried to remove it.
I replaced it with position stored in the local variable and set in the MouseMooved event. And yes! It seems that this weird bug disappears.
UPDATE2: no, it still reproduced. Needs to check my mouse to make sure that it's not hardware issue