From 84ec90e90a90bc9b5a284b5c2e44b05349add5f6 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 21 May 2005 16:59:27 +0000 Subject: [PATCH] Applied patch for bug [ 1205691 ] Modified Fn keys don't work (Paul Konig) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/features.h | 2 +- src/mac/carbon/app.cpp | 74 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/include/wx/features.h b/include/wx/features.h index fbe9692d3a..796dedd445 100644 --- a/include/wx/features.h +++ b/include/wx/features.h @@ -23,7 +23,7 @@ #endif /* the raw keyboard codes are generated under wxGTK and wxMSW only */ -#if defined(__WXGTK__) || defined(__WXMSW__) +#if defined(__WXGTK__) || defined(__WXMSW__) || defined(__WXMAC__) #define wxHAS_RAW_KEY_CODES #else #undef wxHAS_RAW_KEY_CODES diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index e8fc85e903..fe737ce9e6 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -1250,7 +1250,6 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi UInt32 state = 0; 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 ; @@ -1261,6 +1260,39 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi keyval = wxToupper( keyval ) ; } + // Check for NUMPAD keys + if (keyval >= '0' && keyval <= '9' && keycode >= 82 && keycode <= 92) + { + keyval = keyval - '0' + WXK_NUMPAD0; + } + else if (keycode >= 67 && keycode <= 81) + { + switch (keycode) + { + case 76 : + keyval = WXK_NUMPAD_ENTER; + break; + case 81: + keyval = WXK_NUMPAD_EQUAL; + break; + case 67: + keyval = WXK_NUMPAD_MULTIPLY; + break; + case 75: + keyval = WXK_NUMPAD_DIVIDE; + break; + case 78: + keyval = WXK_NUMPAD_SUBTRACT; + break; + case 69: + keyval = WXK_NUMPAD_ADD; + break; + case 65: + keyval = WXK_NUMPAD_DECIMAL; + break; + } // end switch + } + wxKeyEvent event(wxEVT_KEY_DOWN); bool handled = false ; event.m_shiftDown = modifiers & shiftKey; @@ -1271,7 +1303,8 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi #if wxUSE_UNICODE event.m_uniChar = uniChar ; #endif - + event.m_rawCode = keymessage; + event.m_rawFlags = modifiers; event.m_x = wherex; event.m_y = wherey; event.SetTimestamp(when); @@ -1397,7 +1430,6 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier UInt32 state = 0; 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) ; @@ -1405,6 +1437,40 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier { keyval = wxToupper( keyval ) ; } + + // Check for NUMPAD keys + if (keyval >= '0' && keyval <= '9' && keycode >= 82 && keycode <= 92) + { + keyval = keyval - '0' + WXK_NUMPAD0; + } + else if (keycode >= 67 && keycode <= 81) + { + switch (keycode) + { + case 76 : + keyval = WXK_NUMPAD_ENTER; + break; + case 81: + keyval = WXK_NUMPAD_EQUAL; + break; + case 67: + keyval = WXK_NUMPAD_MULTIPLY; + break; + case 75: + keyval = WXK_NUMPAD_DIVIDE; + break; + case 78: + keyval = WXK_NUMPAD_SUBTRACT; + break; + case 69: + keyval = WXK_NUMPAD_ADD; + break; + case 65: + keyval = WXK_NUMPAD_DECIMAL; + break; + } // end switch + } + bool handled = false ; wxKeyEvent event(wxEVT_KEY_UP); @@ -1417,6 +1483,8 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier event.m_uniChar = uniChar ; #endif + event.m_rawCode = keymessage; + event.m_rawFlags = modifiers; event.m_x = wherex; event.m_y = wherey; event.SetTimestamp(when); -- 2.45.2