Return false from wxKeyEvent::IsKeyInCategory(WXK_TAB) for Ctrl+I
Although TAB and Ctrl+I generate the same key code in the events passed to wxEVT_CHAR handlers, it seems more reasonable to only consider the former to be in "TAB category", but not the latter. See #10268. Closes #24254.
This commit is contained in:
parent
6053381b34
commit
460c35ff0e
2 changed files with 60 additions and 2 deletions
|
|
@ -1300,10 +1300,20 @@ enum wxKeyCategoryFlags
|
||||||
/// home and end keys, on and off numeric keypads
|
/// home and end keys, on and off numeric keypads
|
||||||
WXK_CATEGORY_JUMP,
|
WXK_CATEGORY_JUMP,
|
||||||
|
|
||||||
/// tab key, on and off numeric keypads
|
/**
|
||||||
|
Tab key, on and off numeric keypads.
|
||||||
|
|
||||||
|
Note that while `Ctrl+I` and `TAB` keys generate the same key code,
|
||||||
|
only the latter is considered to be in this category.
|
||||||
|
*/
|
||||||
WXK_CATEGORY_TAB,
|
WXK_CATEGORY_TAB,
|
||||||
|
|
||||||
/// backspace and delete keys, on and off numeric keypads
|
/**
|
||||||
|
Backspace and delete keys, on and off numeric keypads.
|
||||||
|
|
||||||
|
Note that while `Ctrl+H` and `BACKSPACE` keys generate the same key
|
||||||
|
code, only the latter is considered to be in this category.
|
||||||
|
*/
|
||||||
WXK_CATEGORY_CUT,
|
WXK_CATEGORY_CUT,
|
||||||
|
|
||||||
/// union of WXK_CATEGORY_ARROW, WXK_CATEGORY_PAGING, and WXK_CATEGORY_JUMP categories
|
/// union of WXK_CATEGORY_ARROW, WXK_CATEGORY_PAGING, and WXK_CATEGORY_JUMP categories
|
||||||
|
|
|
||||||
|
|
@ -849,10 +849,58 @@ bool wxKeyEvent::IsKeyInCategory(int category) const
|
||||||
return (category & WXK_CATEGORY_JUMP) != 0;
|
return (category & WXK_CATEGORY_JUMP) != 0;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
|
// We have to make an extra check for this one, as it's a synonym
|
||||||
|
// for Ctrl-I, but we don't want to recognize Ctrl-I as a TAB key.
|
||||||
|
// As raw key codes are platform-dependent we have to do it in
|
||||||
|
// platform-specific way.
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// Under Windows the native WM_CHAR already does the translation
|
||||||
|
// and so we need to look at the scan code, which is part of the
|
||||||
|
// flags, rather than the key code itself.
|
||||||
|
if ( ((GetRawKeyFlags() >> 16) & 0xff) == 0x17 )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else // !__WXMSW__
|
||||||
|
// For the other platforms we can use the raw key code, but it's
|
||||||
|
// still different, with Mac doing its own thing. We assume all the
|
||||||
|
// other platforms do as GTK does and use either "I" or "i" for
|
||||||
|
// this letter events.
|
||||||
|
switch ( GetRawKeyCode() )
|
||||||
|
{
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
case 0x22: // kVK_ANSI_I
|
||||||
|
#else
|
||||||
|
case 'I':
|
||||||
|
case 'i':
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // __WXMSW__/!__WXMSW__
|
||||||
|
wxFALLTHROUGH;
|
||||||
case WXK_NUMPAD_TAB:
|
case WXK_NUMPAD_TAB:
|
||||||
return (category & WXK_CATEGORY_TAB) != 0;
|
return (category & WXK_CATEGORY_TAB) != 0;
|
||||||
|
|
||||||
case WXK_BACK:
|
case WXK_BACK:
|
||||||
|
// See the comment above for TAB.
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
if ( ((GetRawKeyFlags() >> 16) & 0xff) == 0x23 )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else // !__WXMSW__
|
||||||
|
switch ( GetRawKeyCode() )
|
||||||
|
{
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
case 0x04: // kVK_ANSI_H
|
||||||
|
#else
|
||||||
|
case 'H':
|
||||||
|
case 'h':
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // __WXMSW__/!__WXMSW__
|
||||||
|
wxFALLTHROUGH;
|
||||||
case WXK_DELETE:
|
case WXK_DELETE:
|
||||||
case WXK_NUMPAD_DELETE:
|
case WXK_NUMPAD_DELETE:
|
||||||
return (category & WXK_CATEGORY_CUT) != 0;
|
return (category & WXK_CATEGORY_CUT) != 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue