Better checks for wxMSWKeyboard::VKToWX() return value.
Don't generate key events without any valid key code (this shouldn't normally happen but might on exotic keyboards with keys that we don't know about). Also ensure that we can distinguish between VKToWX() returning dead keys and non-Latin-1 keys by setting wchar_t output parameter to WXK_NONE too in the former case but not the latter. Generate wxEVT_CHAR_HOOK events for non-Latin-1 keys too in Unicode build. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65590 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
246117d444
commit
033428a32c
@ -27,8 +27,9 @@ namespace wxMSWKeyboard
|
||||
// default if lParam == 0.
|
||||
//
|
||||
// Returns WXK_NONE if translation couldn't be done at all (this happens e.g.
|
||||
// for dead keys) or if the key corresponds to a non-ASCII character in which
|
||||
// case uc is filled with its Unicode value.
|
||||
// for dead keys and in this case uc will be WXK_NONE too) or if the key
|
||||
// corresponds to a non-Latin-1 character in which case uc is filled with its
|
||||
// Unicode value.
|
||||
WXDLLIMPEXP_CORE int VKToWX(WXWORD vk, WXLPARAM lParam = 0, wchar_t *uc = NULL);
|
||||
|
||||
// Translate wxKeyCode enum element (passed as int for compatibility reasons)
|
||||
|
@ -3233,7 +3233,11 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
|
||||
wParam,
|
||||
lParam | (KF_EXTENDED << 16)
|
||||
);
|
||||
processed = HandleWindowEvent(event);
|
||||
|
||||
// Don't produce events without any valid character
|
||||
// code (even if this shouldn't normally happen...).
|
||||
if ( event.m_keyCode != WXK_NONE )
|
||||
processed = HandleWindowEvent(event);
|
||||
}
|
||||
}
|
||||
if (message == WM_SYSKEYDOWN) // Let Windows still handle the SYSKEYs
|
||||
@ -6244,26 +6248,23 @@ int VKToWX(WXWORD vk, WXLPARAM lParam, wchar_t *uc)
|
||||
// good idea.
|
||||
wxk = WXK_NONE;
|
||||
}
|
||||
else // Not a dead key.
|
||||
{
|
||||
// In any case return this as a Unicode character value.
|
||||
if ( uc )
|
||||
*uc = wxk;
|
||||
|
||||
// For compatibility with the old non-Unicode code we continue
|
||||
// returning key codes for Latin-1 characters directly
|
||||
// (normally it would really only make sense to do it for the
|
||||
// ASCII characters, not Latin-1 ones).
|
||||
if ( wxk > 255 )
|
||||
{
|
||||
// But for anything beyond this we can only return the key
|
||||
// value as a real Unicode character, not a wxKeyCode
|
||||
// because this enum values clash with Unicode characters
|
||||
// (e.g. WXK_LBUTTON also happens to be U+012C a.k.a.
|
||||
// "LATIN CAPITAL LETTER I WITH BREVE").
|
||||
wxk = WXK_NONE;
|
||||
}
|
||||
//
|
||||
// In any case return this as a Unicode character value.
|
||||
if ( uc )
|
||||
*uc = wxk;
|
||||
|
||||
// For compatibility with the old non-Unicode code we continue
|
||||
// returning key codes for Latin-1 characters directly
|
||||
// (normally it would really only make sense to do it for the
|
||||
// ASCII characters, not Latin-1 ones).
|
||||
if ( wxk > 255 )
|
||||
{
|
||||
// But for anything beyond this we can only return the key
|
||||
// value as a real Unicode character, not a wxKeyCode
|
||||
// because this enum values clash with Unicode characters
|
||||
// (e.g. WXK_LBUTTON also happens to be U+012C a.k.a.
|
||||
// "LATIN CAPITAL LETTER I WITH BREVE").
|
||||
wxk = WXK_NONE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6320,14 +6321,14 @@ int VKToWX(WXWORD vk, WXLPARAM lParam, wchar_t *uc)
|
||||
// A simple alphanumeric key and the values of them coincide in
|
||||
// Windows and wx for both ASCII and Unicode codes.
|
||||
wxk = vk;
|
||||
|
||||
if ( uc )
|
||||
*uc = vk;
|
||||
}
|
||||
else // Something we simply don't know about at all.
|
||||
{
|
||||
wxk = WXK_NONE;
|
||||
}
|
||||
|
||||
if ( uc )
|
||||
*uc = vk;
|
||||
}
|
||||
|
||||
return wxk;
|
||||
@ -6599,7 +6600,11 @@ wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
|
||||
{
|
||||
wchar_t uc;
|
||||
int id = wxMSWKeyboard::VKToWX(wParam, lParam, &uc);
|
||||
if ( id != WXK_NONE )
|
||||
if ( id != WXK_NONE
|
||||
#if wxUSE_UNICODE
|
||||
|| uc != WXK_NONE
|
||||
#endif // wxUSE_UNICODE
|
||||
)
|
||||
{
|
||||
const wxWindow * const win = wxGetActiveWindow();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user