]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't set Unicode key code in key events to non-Unicode values in wxGTK.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Aug 2010 22:38:54 +0000 (22:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Aug 2010 22:38:54 +0000 (22:38 +0000)
Only assign the wx key code wxKeyEvent::m_uniChar if it's a key corresponding
to an ASCII symbol, don't do it for the values outside of ASCII range such as
all the special WXK_ constants. It doesn't make sense to generate Unicode key
codes for e.g. cursor key presses.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65240 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp

index eb4d2df8cd2fab92486794d3225a6edbff796de1..30985280bdfbfc24d74643e7fb669ad6e621fa38 100644 (file)
@@ -688,7 +688,14 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event,
     event.m_rawFlags = 0;
 #if wxUSE_UNICODE
     event.m_uniChar = gdk_keyval_to_unicode(gdk_event->keyval);
-#endif
+    if ( !event.m_uniChar && event.m_keyCode <= WXK_DELETE )
+    {
+        // Set Unicode key code to the ASCII equivalent for compatibility. E.g.
+        // let RETURN generate the key event with both key and Unicode key
+        // codes of 13.
+        event.m_uniChar = event.m_keyCode;
+    }
+#endif // wxUSE_UNICODE
     wxGetMousePosition( &x, &y );
     win->ScreenToClient( &x, &y );
     event.m_x = x;
@@ -791,17 +798,11 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event,
     if ( !key_code )
         return false;
 
+    event.m_keyCode = key_code;
+
     // now fill all the other fields
     wxFillOtherKeyEventFields(event, win, gdk_event);
 
-    event.m_keyCode = key_code;
-#if wxUSE_UNICODE
-    if ( gdk_event->type == GDK_KEY_PRESS ||  gdk_event->type == GDK_KEY_RELEASE )
-    {
-        event.m_uniChar = key_code;
-    }
-#endif
-
     return true;
 }