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
// default if lParam == 0.
//
// Returns WXK_NONE if translation couldn't be done at all (this happens e.g.
// 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)
WXDLLIMPEXP_CORE int VKToWX(WXWORD vk, WXLPARAM lParam = 0, wchar_t *uc = NULL);
// Translate wxKeyCode enum element (passed as int for compatibility reasons)
wParam,
lParam | (KF_EXTENDED << 16)
);
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
}
}
if (message == WM_SYSKEYDOWN) // Let Windows still handle the SYSKEYs
// good idea.
wxk = WXK_NONE;
}
// 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;
// A simple alphanumeric key and the values of them coincide in
// Windows and wx for both ASCII and Unicode codes.
wxk = vk;
// 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;
}
}
else // Something we simply don't know about at all.
{
wxk = WXK_NONE;
}
+
+ if ( uc )
+ *uc = vk;
{
wchar_t uc;
int id = wxMSWKeyboard::VKToWX(wParam, lParam, &uc);
{
wchar_t uc;
int id = wxMSWKeyboard::VKToWX(wParam, lParam, &uc);
+ if ( id != WXK_NONE
+#if wxUSE_UNICODE
+ || uc != WXK_NONE
+#endif // wxUSE_UNICODE
+ )
{
const wxWindow * const win = wxGetActiveWindow();
{
const wxWindow * const win = wxGetActiveWindow();