]> git.saurik.com Git - wxWidgets.git/commitdiff
Ctrl-letter --> ascii(1..26) for EVT_CHAR events now also works when
authorRobin Dunn <robin@alldunn.com>
Tue, 13 Jun 2006 18:52:28 +0000 (18:52 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 13 Jun 2006 18:52:28 +0000 (18:52 +0000)
CAPS-LOCK is on.

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

src/gtk/window.cpp

index b7ab6c34c83d9618667897564e13a330a35ac30d..de6677ff1952567fc728011d2dcc638e390b09d3 100644 (file)
@@ -531,6 +531,18 @@ gtk_window_expose_callback( GtkWidget *widget,
 // "key_press_event" from any window
 //-----------------------------------------------------------------------------
 
+// These are used when transforming Ctrl-alpha to ascii values 1-26
+inline bool wxIsLowerChar(int code)
+{
+    return (code >= 'a' && code <= 'z' );
+}
+
+inline bool wxIsUpperChar(int code)
+{
+    return (code >= 'A' && code <= 'Z' );
+}
+
+
 // set WXTRACE to this to see the key event codes on the console
 #define TRACE_KEYS  _T("keyevent")
 
@@ -1082,9 +1094,13 @@ gtk_window_key_press_callback( GtkWidget *widget,
 
             // 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' )
+            if ( event.ControlDown() &&
+                 ( wxIsLowerChar(key_code) || wxIsUpperChar(key_code) ))
             {
-                event.m_keyCode = key_code - 'a' + 1;
+                if ( wxIsLowerChar(key_code) )
+                    event.m_keyCode = key_code - 'a' + 1;
+                if ( wxIsUpperChar(key_code) )
+                    event.m_keyCode = key_code - 'A' + 1;
 #if wxUSE_UNICODE
                 event.m_uniChar = event.m_keyCode;
 #endif
@@ -1223,8 +1239,14 @@ gtk_wxwindow_commit_cb (GtkIMContext *context,
 
         // 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' )
+        if ( event.ControlDown() &&
+             ( wxIsLowerChar(*pstr) || wxIsUpperChar(*pstr) ))
         {
+            if ( wxIsLowerChar(*pstr) )
+                event.m_keyCode = *pstr - 'a' + 1;
+            if ( wxIsUpperChar(*pstr) )
+                event.m_keyCode = *pstr - 'A' + 1;
+
             event.m_keyCode = *pstr - 'a' + 1;
 #if wxUSE_UNICODE
             event.m_uniChar = event.m_keyCode;