From e999b903ca76951f79936b639e65a9db5adfce37 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jul 2011 21:54:21 +0000 Subject: [PATCH] Generate events with WXK_NONE Unicode keys for non-characters in wxOSX. The keyboard keys not corresponding to real characters, such as cursor arrows or function keys, must generate wxKeyEvents with WXK_NONE as Unicode key code to make it possible to distinguish them from the printable characters but wxOSX generated events with valid Unicode key codes for them instead. Avoid this by excluding Unicode key codes corresponding to code points in the Unicode private use area: while this doesn't seem to be documented anywhere, all non-printable characters seem to have their Unicode representation inside it. This change brings wxOSX keyboard event generation in line with the other ports and, as a side effect, also closes #12423. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/window.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index b859eba7cb..ec4381d4c0 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -368,7 +368,16 @@ void wxWidgetCocoaImpl::SetupKeyEvent(wxKeyEvent &wxevent , NSEvent * nsEvent, N } #if wxUSE_UNICODE - wxevent.m_uniChar = aunichar; + // OS X generates events with key codes in Unicode private use area for + // unprintable symbols such as cursor arrows (WXK_UP is mapped to U+F700) + // and function keys (WXK_F2 is U+F705). We don't want to use them as the + // result of wxKeyEvent::GetUnicodeKey() however as it's supposed to return + // WXK_NONE for "non characters" so explicitly exclude them. + // + // We only exclude the private use area inside the Basic Multilingual Plane + // as key codes beyond it don't seem to be currently used. + if ( !(aunichar >= 0xe000 && aunichar < 0xf900) ) + wxevent.m_uniChar = aunichar; #endif wxevent.m_keyCode = keyval; -- 2.45.2