From ef08713a5b339ac1770e14ca7271fcfa02607ce0 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 23 Aug 2002 12:43:28 +0000 Subject: [PATCH] brought key values of EVT_KEY and EVT_CHAR in synch with wxMSW and wxGTK... git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/app.cpp | 22 ++++++++++++++-------- src/mac/carbon/app.cpp | 22 ++++++++++++++-------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 6473c26f07..b5855a013b 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -1831,24 +1831,30 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi keychar = short(keymessage & charCodeMask); keycode = short(keymessage & keyCodeMask) >> 8 ; - if ( (modifiers & controlKey) ) + if ( modifiers & ( controlKey|shiftKey|optionKey ) ) { // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier // and look at the character after UInt32 state = 0; - UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~controlKey)) | keycode, &state); + UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); keychar = short(keyInfo & charCodeMask); keycode = short(keyInfo & keyCodeMask) >> 8 ; } long keyval = wxMacTranslateKey(keychar, keycode) ; - + long realkeyval = keyval ; + if ( keyval == keychar ) + { + // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY + realkeyval = short(keymessage & charCodeMask) ; + } + wxKeyEvent event(wxEVT_KEY_DOWN); bool handled = false ; event.m_shiftDown = modifiers & shiftKey; event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - event.m_keyCode = wxToupper(keyval ); + event.m_keyCode = keyval ; event.m_x = wherex; event.m_y = wherey; @@ -1884,7 +1890,7 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi event.Skip( FALSE ) ; event.SetEventType( wxEVT_CHAR ) ; // raw value again - event.m_keyCode = keyval ; + event.m_keyCode = realkeyval ; handled = focus->GetEventHandler()->ProcessEvent( event ) ; if ( handled && event.GetSkipped() ) @@ -1969,12 +1975,12 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier short keychar ; keychar = short(keymessage & charCodeMask); keycode = short(keymessage & keyCodeMask) >> 8 ; - if ( (modifiers & controlKey) ) + if ( modifiers & ( controlKey|shiftKey|optionKey ) ) { // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier // and look at the character after UInt32 state = 0; - UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~controlKey)) | keycode, &state); + UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); keychar = short(keyInfo & charCodeMask); keycode = short(keyInfo & keyCodeMask) >> 8 ; } @@ -1987,7 +1993,7 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - event.m_keyCode = wxToupper(keyval ); + event.m_keyCode = keyval ; event.m_x = wherex; event.m_y = wherey; diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 6473c26f07..b5855a013b 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -1831,24 +1831,30 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi keychar = short(keymessage & charCodeMask); keycode = short(keymessage & keyCodeMask) >> 8 ; - if ( (modifiers & controlKey) ) + if ( modifiers & ( controlKey|shiftKey|optionKey ) ) { // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier // and look at the character after UInt32 state = 0; - UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~controlKey)) | keycode, &state); + UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); keychar = short(keyInfo & charCodeMask); keycode = short(keyInfo & keyCodeMask) >> 8 ; } long keyval = wxMacTranslateKey(keychar, keycode) ; - + long realkeyval = keyval ; + if ( keyval == keychar ) + { + // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY + realkeyval = short(keymessage & charCodeMask) ; + } + wxKeyEvent event(wxEVT_KEY_DOWN); bool handled = false ; event.m_shiftDown = modifiers & shiftKey; event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - event.m_keyCode = wxToupper(keyval ); + event.m_keyCode = keyval ; event.m_x = wherex; event.m_y = wherey; @@ -1884,7 +1890,7 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi event.Skip( FALSE ) ; event.SetEventType( wxEVT_CHAR ) ; // raw value again - event.m_keyCode = keyval ; + event.m_keyCode = realkeyval ; handled = focus->GetEventHandler()->ProcessEvent( event ) ; if ( handled && event.GetSkipped() ) @@ -1969,12 +1975,12 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier short keychar ; keychar = short(keymessage & charCodeMask); keycode = short(keymessage & keyCodeMask) >> 8 ; - if ( (modifiers & controlKey) ) + if ( modifiers & ( controlKey|shiftKey|optionKey ) ) { // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier // and look at the character after UInt32 state = 0; - UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~controlKey)) | keycode, &state); + UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); keychar = short(keyInfo & charCodeMask); keycode = short(keyInfo & keyCodeMask) >> 8 ; } @@ -1987,7 +1993,7 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - event.m_keyCode = wxToupper(keyval ); + event.m_keyCode = keyval ; event.m_x = wherex; event.m_y = wherey; -- 2.45.2