- // As above, make a copy of the event first.
- wxKeyEvent eventChar(event);
- eventChar.SetEventType(wxEVT_CHAR);
- return win->HandleWindowEvent(eventChar);
+ return false;
+}
+
+// Adjust wxEVT_CHAR event key code fields. This function takes care of two
+// conventions:
+// (a) Ctrl-letter key presses generate key codes in range 1..26
+// (b) Unicode key codes are same as key codes for the codes in 1..255 range
+void AdjustCharEventKeyCodes(wxKeyEvent& event)
+{
+ const int code = event.m_keyCode;
+
+ // Check for (a) above.
+ if ( event.ControlDown() )
+ {
+ // We intentionally don't use isupper/lower() here, we really need
+ // ASCII letters only as it doesn't make sense to translate any other
+ // ones into this range which has only 26 slots.
+ if ( code >= 'a' && code <= 'z' )
+ event.m_keyCode = code - 'a' + 1;
+ else if ( code >= 'A' && code <= 'Z' )
+ event.m_keyCode = code - 'A' + 1;
+
+#if wxUSE_UNICODE
+ // Adjust the Unicode equivalent in the same way too.
+ if ( event.m_keyCode != code )
+ event.m_uniChar = event.m_keyCode;
+#endif // wxUSE_UNICODE
+ }
+
+#if wxUSE_UNICODE
+ // Check for (b) from above.
+ //
+ // FIXME: Should we do it for key codes up to 255?
+ if ( !event.m_uniChar && code < WXK_DELETE )
+ event.m_uniChar = code;
+#endif // wxUSE_UNICODE