From e7b12eece089de08a761d5862ff92329e5038574 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 11 Sep 2010 10:18:57 +0000 Subject: [PATCH] Improve printing out of pressed keys in the keyboard sample. Add missing elements of wxKeyCode enum ("Windows" and "Command" keys) to the GetVirtualKeyCodeName() function in the sample. Also output "unknown" and not blank for WXK_NONE. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65524 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/keyboard/keyboard.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/samples/keyboard/keyboard.cpp b/samples/keyboard/keyboard.cpp index 13c1cd0731..f218f6bbaf 100644 --- a/samples/keyboard/keyboard.cpp +++ b/samples/keyboard/keyboard.cpp @@ -335,7 +335,12 @@ const char* GetVirtualKeyCodeName(int keycode) WXK_(NUMPAD_SUBTRACT) WXK_(NUMPAD_DECIMAL) WXK_(NUMPAD_DIVIDE) + + WXK_(WINDOWS_LEFT) + WXK_(WINDOWS_RIGHT) + WXK_(COMMAND) #undef WXK_ + default: return NULL; } @@ -352,11 +357,14 @@ wxString GetKeyName(const wxKeyEvent &event) return wxString::Format("Ctrl-%c", (unsigned char)('A' + keycode - 1)); if ( keycode >= 32 && keycode < 128 ) return wxString::Format("'%c'", (unsigned char)keycode); + #if wxUSE_UNICODE - return wxString::Format("'%c'", event.GetUnicodeKey()); -#else - return "unknown"; + int uc = event.GetUnicodeKey(); + if ( uc != WXK_NONE ) + return wxString::Format("'%c'", uc); #endif + + return "unknown"; } -- 2.47.2