From: Robin Dunn Date: Sun, 5 Feb 2006 22:10:13 +0000 (+0000) Subject: For consistency with the docs and with wxMSW the keycode for X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1dabdced0ebd3fb19419b5a4737e2e30d0c8bd12 For consistency with the docs and with wxMSW the keycode for Ctrl-letter EVT_CHAR events should be in the range 1-26. Also, make the m_uniChar value match the keycode for KEY_UP/DOWN events for letters. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37339 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fe8da3d23a..dc244f803a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -830,6 +830,10 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event, event.m_rawFlags = 0; #if wxUSE_UNICODE event.m_uniChar = gdk_keyval_to_unicode(gdk_event->keyval); + if ( gdk_event->type == GDK_KEY_PRESS || gdk_event->type == GDK_KEY_RELEASE ) + { + event.m_uniChar = toupper(event.m_uniChar); + } #endif wxGetMousePosition( &x, &y ); win->ScreenToClient( &x, &y ); @@ -1066,6 +1070,16 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, event.m_keyCode = key_code; + // To conform to the docs we need to translate Ctrl-alpha + // characters to values in the range 1-26. + if (event.ControlDown() && key_code >= 'a' && key_code <= 'z' ) + { + event.m_keyCode = key_code - 'a' + 1; +#if wxUSE_UNICODE + event.m_uniChar = event.m_keyCode; +#endif + } + // Implement OnCharHook by checking ancestor top level windows wxWindow *parent = win; while (parent && !parent->IsTopLevel()) @@ -1200,6 +1214,17 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context, #else event.m_keyCode = *pstr; #endif // wxUSE_UNICODE + + // To conform to the docs we need to translate Ctrl-alpha + // characters to values in the range 1-26. + if (event.ControlDown() && *pstr >= 'a' && *pstr <= 'z' ) + { + event.m_keyCode = *pstr - 'a' + 1; +#if wxUSE_UNICODE + event.m_uniChar = event.m_keyCode; +#endif + } + if (parent) { event.SetEventType( wxEVT_CHAR_HOOK );