Only give messages about unsupported accelerators in wxGTK

Doing this under all platforms results in too many false positives,
which can't be avoided currently, e.g. even if an application uses "Tab"
as an accelerator only under MSW, these messages still appear (in debug
builds, but this is more than sufficient for them to be annoying).

For now, restrict the messages to wxGTK only. In the future we could
revert to giving them under all platforms if we provide some way of
disabling them, e.g. qualifying accelerators with "[port]" or "[!port]"
string before them.

This partially reverts 6596f5a98d, see
https://github.com/wxWidgets/wxWidgets/pull/1505

Closes https://github.com/wxWidgets/wxWidgets/pull/1566
This commit is contained in:
Vadim Zeitlin
2019-09-26 23:13:14 +02:00
parent 9a0072b12e
commit 68b36aed6d
3 changed files with 79 additions and 138 deletions

View File

@@ -156,96 +156,6 @@ static int IsNumberedAccelKey(const wxString& str,
return prefixCode + num - first;
}
// static
bool wxAcceleratorEntry::ValidateKey(int flags, int keycode)
{
wxString keyname;
if ( keycode )
{
for ( size_t n = 0; n < WXSIZEOF(wxKeyNames); n++ )
{
const wxKeyName& kn = wxKeyNames[n];
if ( kn.code == keycode )
{
keyname = kn.name;
break;
}
}
if ( keyname.IsEmpty() && keycode >= WXK_SPECIAL1 && keycode <= WXK_SPECIAL20 )
keyname << wxS("SPECIAL") << keycode - WXK_SPECIAL1 + 1;
}
bool valid = true;
switch ( keycode )
{
/*
The following keycodes must have modifier keys to be valid on GTK
*/
case WXK_UP:
case WXK_DOWN:
case WXK_LEFT:
case WXK_RIGHT:
case WXK_NUMPAD_UP:
case WXK_NUMPAD_DOWN:
case WXK_NUMPAD_LEFT:
case WXK_NUMPAD_RIGHT:
if ( !flags )
{
valid = false;
wxLogDebug( "Compatibility issue: %s key must have modifiers to be an accelerator key on GTK",
keyname );
}
break;
/*
The following keycodes have been shown not to work as accelerator
keys on GTK (see https://trac.wxwidgets.org/ticket/10049)
and are not valid
(see gtkaccelgroup.c inside gtk_accelerator_valid())
*/
case WXK_COMMAND: // Same as WXK_CONTROL
case WXK_SHIFT:
case WXK_ALT:
case WXK_SCROLL: // Scroll lock
case WXK_CAPITAL: // Caps lock
case WXK_NUMLOCK:
case WXK_NUMPAD_TAB:
case WXK_TAB:
case WXK_WINDOWS_LEFT:
case WXK_WINDOWS_RIGHT:
/*
The following keycodes do not map clearly into a GTK keycode,
so they are not included in the accelerator mapping:
*/
case WXK_ADD:
case WXK_SEPARATOR:
case WXK_SUBTRACT:
case WXK_DECIMAL:
case WXK_DIVIDE:
case WXK_SNAPSHOT:
/*
The following special codes do not map into GTK keycodes,
see gdk/keynames.txt
*/
case WXK_SPECIAL1: case WXK_SPECIAL2: case WXK_SPECIAL3:
case WXK_SPECIAL4: case WXK_SPECIAL5: case WXK_SPECIAL6:
case WXK_SPECIAL7: case WXK_SPECIAL8: case WXK_SPECIAL9:
case WXK_SPECIAL10: case WXK_SPECIAL11: case WXK_SPECIAL12:
case WXK_SPECIAL13: case WXK_SPECIAL14: case WXK_SPECIAL15:
case WXK_SPECIAL16: case WXK_SPECIAL17: case WXK_SPECIAL18:
case WXK_SPECIAL19: case WXK_SPECIAL20:
valid = false;
wxLogDebug( "Compatibility issue: %s is not supported as a keyboard accelerator key on GTK",
keyname );
break;
}
return valid;
}
/* static */
bool
wxAcceleratorEntry::ParseAccel(const wxString& text, int *flagsOut, int *keyOut)