mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-23 11:21:30 +11:00
Fixed button hold on window exit
On Windows when moving the cursor out of the window while holding a mouse button down it would still be set to true when entering the window even if the button had been released outside of the window. Closes #280
This commit is contained in:
parent
bedec9b59d
commit
ad9648769d
|
@ -217,6 +217,18 @@ unsafe extern "system" fn wnd_proc(
|
|||
|
||||
winuser::WM_LBUTTONUP => wnd.mouse.state[0] = false,
|
||||
|
||||
winuser::WM_MOUSEMOVE => {
|
||||
let button_checks = [winuser::MK_LBUTTON, winuser::MK_MBUTTON, winuser::MK_RBUTTON];
|
||||
|
||||
for i in 0..3 {
|
||||
if (wparam & button_checks[i]) == button_checks[i] {
|
||||
wnd.mouse.state[i] = true;
|
||||
} else {
|
||||
wnd.mouse.state[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
winuser::WM_MBUTTONDOWN => wnd.mouse.state[1] = true,
|
||||
|
||||
winuser::WM_MBUTTONUP => wnd.mouse.state[1] = false,
|
||||
|
|
Loading…
Reference in a new issue