1
0
Fork 0

Merge pull request #102 from DGriffin91/master

add scrollwheel support for windows
This commit is contained in:
william light 2021-10-10 02:11:07 +02:00 committed by GitHub
commit 6172090be3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,8 +9,8 @@ use winapi::um::winuser::{
DestroyWindow, SetProcessDpiAwarenessContext, SetWindowPos,
GetDpiForWindow,
CS_OWNDC, GWLP_USERDATA, IDC_ARROW,
MSG, WM_CLOSE, WM_CREATE, WM_MOUSEMOVE, WM_SHOWWINDOW, WM_TIMER, WM_NCDESTROY,
WNDCLASSW, WS_CAPTION, WS_CHILD, WS_CLIPSIBLINGS, WS_MAXIMIZEBOX, WS_MINIMIZEBOX,
MSG, WM_CLOSE, WM_CREATE, WM_MOUSEMOVE, WM_MOUSEWHEEL, WHEEL_DELTA, WM_SHOWWINDOW, WM_TIMER,
WM_NCDESTROY, WNDCLASSW, WS_CAPTION, WS_CHILD, WS_CLIPSIBLINGS, WS_MAXIMIZEBOX, WS_MINIMIZEBOX,
WS_POPUPWINDOW, WS_SIZEBOX, WS_VISIBLE, WM_DPICHANGED, WM_CHAR, WM_SYSCHAR, WM_KEYDOWN,
WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP, WM_INPUTLANGCHANGE, WM_SIZE,
GET_XBUTTON_WPARAM, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP,
@ -30,7 +30,7 @@ use raw_window_handle::{
};
use crate::{
Event, MouseButton, MouseEvent, WindowEvent,
Event, MouseButton, MouseEvent, ScrollDelta, WindowEvent,
WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy, PhyPoint, PhySize
};
@ -89,6 +89,22 @@ unsafe extern "system" fn wnd_proc(
);
return 0;
}
WM_MOUSEWHEEL => {
let value = (wparam >> 16) as i16;
let value = value as i32;
let value = value as f32 / WHEEL_DELTA as f32;
let mut window_state = (&*window_state_ptr).borrow_mut();
window_state.handler.on_event(
&mut window,
Event::Mouse(MouseEvent::WheelScrolled(ScrollDelta::Lines {
x: 0.0,
y: value,
})),
);
return 0;
}
WM_LBUTTONDOWN | WM_LBUTTONUP | WM_MBUTTONDOWN | WM_MBUTTONUP |
WM_RBUTTONDOWN | WM_RBUTTONUP | WM_XBUTTONDOWN | WM_XBUTTONUP => {