From e4a2016a21508a6b594410ae75375c18188a0cec Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Tue, 21 May 2002 21:33:29 +0000 Subject: [PATCH] fix Alt key handling --- panda/src/wdxdisplay/wdxGraphicsWindow.cxx | 19 +++++++++++------- panda/src/wdxdisplay8/wdxGraphicsWindow8.cxx | 15 +++++++++----- panda/src/wgldisplay/wglGraphicsWindow.cxx | 21 ++++++++++++-------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx index 216f71fd21..f98e8eec72 100644 --- a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx +++ b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx @@ -492,18 +492,22 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } break; - case WM_SYSKEYDOWN: - // want to use defwindproc on Alt syskey so Alt-F4 works, etc - // but do want to bypass defwindproc F10 behavior (it activates - // the main menu, but we have none) + case WM_SYSKEYDOWN: { + // Alt and F10 are sent as WM_SYSKEYDOWN instead of WM_KEYDOWN + // want to use defwindproc on Alt syskey so std windows cmd Alt-F4 works, etc + POINT point; + GetCursorPos(&point); + ScreenToClient(hwnd, &point); + handle_keypress(lookup_key(wparam), point.x, point.y); if (wparam == VK_F10) { + //bypass default windproc F10 behavior (it activates the main menu, but we have none) return 0; } - break; + } + break; case WM_KEYDOWN: { POINT point; - GetCursorPos(&point); ScreenToClient(hwnd, &point); handle_keypress(lookup_key(wparam), point.x, point.y); @@ -2684,8 +2688,9 @@ lookup_key(WPARAM wparam) const { case VK_MENU: case VK_LMENU: - case VK_RMENU: + case VK_RMENU: { return KeyboardButton::alt(); + } default: int key = MapVirtualKey(wparam, 2); diff --git a/panda/src/wdxdisplay8/wdxGraphicsWindow8.cxx b/panda/src/wdxdisplay8/wdxGraphicsWindow8.cxx index 6b103e43a8..037291ec2e 100644 --- a/panda/src/wdxdisplay8/wdxGraphicsWindow8.cxx +++ b/panda/src/wdxdisplay8/wdxGraphicsWindow8.cxx @@ -492,14 +492,19 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } break; - case WM_SYSKEYDOWN: - // want to use defwindproc on Alt syskey so Alt-F4 works, etc - // but do want to bypass defwindproc F10 behavior (it activates - // the main menu, but we have none) + case WM_SYSKEYDOWN: { + // Alt and F10 are sent as WM_SYSKEYDOWN instead of WM_KEYDOWN + // want to use defwindproc on Alt syskey so std windows cmd Alt-F4 works, etc + POINT point; + GetCursorPos(&point); + ScreenToClient(hwnd, &point); + handle_keypress(lookup_key(wparam), point.x, point.y); if (wparam == VK_F10) { + //bypass default windproc F10 behavior (it activates the main menu, but we have none) return 0; } - break; + } + break; case WM_KEYDOWN: { POINT point; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index f01b2f1c9a..f11b8868f8 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -1799,14 +1799,19 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } break; - case WM_SYSKEYDOWN: - // want to use defwindproc on Alt syskey so Alt-F4 works, etc - // but do want to bypass defwindproc F10 behavior (it activates - // the main menu, but we have none) - if (wparam == VK_F10) { - return 0; - } - break; + case WM_SYSKEYDOWN: { + // Alt and F10 are sent as WM_SYSKEYDOWN instead of WM_KEYDOWN + // want to use defwindproc on Alt syskey so std windows cmd Alt-F4 works, etc + POINT point; + GetCursorPos(&point); + ScreenToClient(hwnd, &point); + handle_keypress(lookup_key(wparam), point.x, point.y); + if (wparam == VK_F10) { + //bypass default windproc F10 behavior (it activates the main menu, but we have none) + return 0; + } + } + break; case WM_KEYDOWN: { POINT point;