From fae10c60720292472c69485e73cf816bbec512ee Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Tue, 21 Nov 2017 02:12:51 -0700 Subject: [PATCH] Emit delete character on Windows (#352) --- src/platform/windows/events_loop.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platform/windows/events_loop.rs b/src/platform/windows/events_loop.rs index ce9fdd8f..f362d9a4 100644 --- a/src/platform/windows/events_loop.rs +++ b/src/platform/windows/events_loop.rs @@ -494,6 +494,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, winapi::WM_KEYDOWN | winapi::WM_SYSKEYDOWN => { use events::ElementState::Pressed; + use events::VirtualKeyCode; if msg == winapi::WM_SYSKEYDOWN && wparam as i32 == winapi::VK_F4 { user32::DefWindowProcW(window, msg, wparam, lparam) } else { @@ -510,6 +511,14 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, } } }); + // Windows doesn't emit a delete character by default, but in order to make it + // consistent with the other platforms we'll emit a delete character here. + if vkey == Some(VirtualKeyCode::Delete) { + send_event(Event::WindowEvent { + window_id: SuperWindowId(WindowId(window)), + event: WindowEvent::ReceivedCharacter('\u{7F}'), + }); + } 0 } },