From 2a8d09fb285f2b382b9fc7d92e6beb5ea220605e Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Fri, 8 Jul 2016 14:27:25 +0200 Subject: [PATCH] Char input support on Windows --- src/os/windows/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs index 507146f..32b9867 100644 --- a/src/os/windows/mod.rs +++ b/src/os/windows/mod.rs @@ -145,6 +145,11 @@ fn update_key_state(window: &mut Window, wparam: u32, state: bool) { } } +fn char_down(window: &mut Window, code_point: u32) { + if let Some(ref mut callback) = window.key_handler.key_callback { + callback.add_char(code_point); + } +} #[cfg(target_arch = "x86_64")] unsafe fn set_window_long(window: winapi::HWND, data: winapi::LONG_PTR) -> winapi::LONG_PTR { @@ -203,6 +208,14 @@ unsafe extern "system" fn wnd_proc(window: winapi::HWND, return 0; } + winapi::winuser::WM_CHAR => { + char_down(wnd, wparam as u32); + } + + winapi::winuser::WM_SYSCHAR => { + char_down(wnd, wparam as u32); + } + winapi::winuser::WM_LBUTTONDOWN => { wnd.mouse.state[0] = true }