mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
Hotkey handling: disable usage of keyboard modifier flag wxMOD_ALTGR.
The flag wxMOD_ALTGR is defined in wxWidgets as wxMOD_CONTROL|wxMOD_ALT So AltGr key cannot used as modifier key because it is the same as Alt key + Ctrl key that is already handled. So the previous code did not work with modifiers Alt key, Ctrl key and Altgr key Fixes https://gitlab.com/kicad/code/kicad/-/issues/21696
This commit is contained in:
parent
5e2fd084b9
commit
11cc86e586
@ -158,6 +158,43 @@ TOOL_DISPATCHER::~TOOL_DISPATCHER()
|
||||
delete st;
|
||||
}
|
||||
|
||||
int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState )
|
||||
{
|
||||
int mods = 0;
|
||||
int wxmods = aState->GetModifiers();
|
||||
|
||||
// Returns the state of key modifiers (Alt, Ctrl and so on). Be carefull:
|
||||
// the flag wxMOD_ALTGR is defined in wxWidgets as wxMOD_CONTROL|wxMOD_ALT
|
||||
// So AltGr key cannot used as modifier key because it is the same as Alt key + Ctrl key.
|
||||
#if CAN_USE_ALTGR_KEY
|
||||
if( wxmods & wxMOD_ALTGR )
|
||||
mods |= MD_ALTGR;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( wxmods & wxMOD_CONTROL )
|
||||
mods |= MD_CTRL;
|
||||
|
||||
if( wxmods & wxMOD_ALT )
|
||||
mods |= MD_ALT;
|
||||
}
|
||||
|
||||
if( wxmods & wxMOD_SHIFT )
|
||||
mods |= MD_SHIFT;
|
||||
|
||||
#ifdef wxMOD_META
|
||||
if( wxmods & wxMOD_META )
|
||||
mods |= MD_META;
|
||||
#endif
|
||||
|
||||
#ifdef wxMOD_WIN
|
||||
if( wxmods & wxMOD_WIN )
|
||||
mods |= MD_SUPER;
|
||||
#endif
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
||||
|
||||
void TOOL_DISPATCHER::ResetState()
|
||||
{
|
||||
|
@ -642,9 +642,13 @@ void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
|
||||
|
||||
int mods = aKeyStroke.GetModifiers();
|
||||
|
||||
if( mods & wxMOD_ALTGR )
|
||||
hotkey += MD_ALTGR;
|
||||
// the flag wxMOD_ALTGR is defined in wxWidgets as wxMOD_CONTROL|wxMOD_ALT
|
||||
// So AltGr key cannot used as modifier key because it is the same as Alt key + Ctrl key.
|
||||
#if CAN_USE_ALTGR_KEY
|
||||
if( wxmods & wxMOD_ALTGR )
|
||||
mods |= MD_ALTGR;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( mods & wxMOD_CONTROL )
|
||||
hotkey += MD_CTRL;
|
||||
|
@ -670,7 +670,7 @@ long WIDGET_HOTKEY_LIST::MapKeypressToKeycode( const wxKeyEvent& aEvent )
|
||||
{
|
||||
long key = aEvent.GetKeyCode();
|
||||
bool is_tab = aEvent.IsKeyInCategory( WXK_CATEGORY_TAB );
|
||||
|
||||
printf("key %lX mod %X\n", key, aEvent.GetModifiers());
|
||||
if( key == WXK_ESCAPE )
|
||||
{
|
||||
return 0;
|
||||
@ -698,9 +698,13 @@ long WIDGET_HOTKEY_LIST::MapKeypressToKeycode( const wxKeyEvent& aEvent )
|
||||
if( ( mods & wxMOD_SHIFT ) && ( keyIsLetter || key > 256 || key == 9 || key == 32 ) )
|
||||
key |= MD_SHIFT;
|
||||
|
||||
if( mods & wxMOD_ALTGR )
|
||||
key |= MD_ALTGR;
|
||||
// the flag wxMOD_ALTGR is defined in wxWidgets as wxMOD_CONTROL|wxMOD_ALT
|
||||
// So AltGr key cannot used as modifier key because it is the same as Alt key + Ctrl key.
|
||||
#if CAN_USE_ALTGR_KEY
|
||||
if( wxmods & wxMOD_ALTGR )
|
||||
mods |= MD_ALTGR;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( mods & wxMOD_CONTROL )
|
||||
key |= MD_CTRL;
|
||||
|
@ -548,9 +548,13 @@ void HIERARCHY_PANE::onCharHook( wxKeyEvent& aKeyStroke )
|
||||
|
||||
int mods = aKeyStroke.GetModifiers();
|
||||
|
||||
if( mods & wxMOD_ALTGR )
|
||||
hotkey += MD_ALTGR;
|
||||
// the flag wxMOD_ALTGR is defined in wxWidgets as wxMOD_CONTROL|wxMOD_ALT
|
||||
// So AltGr key cannot used as modifier key because it is the same as Alt key + Ctrl key.
|
||||
#if CAN_USE_ALTGR_KEY
|
||||
if( wxmods & wxMOD_ALTGR )
|
||||
mods |= MD_ALTGR;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( mods & wxMOD_CONTROL )
|
||||
hotkey += MD_CTRL;
|
||||
|
@ -84,38 +84,9 @@ private:
|
||||
/// Returns the instance of VIEW, used by the application.
|
||||
KIGFX::VIEW* getView();
|
||||
|
||||
/// Saves the state of key modifiers (Alt, Ctrl and so on).
|
||||
static int decodeModifiers( const wxKeyboardState* aState )
|
||||
{
|
||||
int mods = 0;
|
||||
int wxmods = aState->GetModifiers();
|
||||
|
||||
if( wxmods & wxMOD_ALTGR )
|
||||
mods |= MD_ALTGR;
|
||||
else
|
||||
{
|
||||
if( wxmods & wxMOD_CONTROL )
|
||||
mods |= MD_CTRL;
|
||||
|
||||
if( wxmods & wxMOD_ALT )
|
||||
mods |= MD_ALT;
|
||||
}
|
||||
|
||||
if( wxmods & wxMOD_SHIFT )
|
||||
mods |= MD_SHIFT;
|
||||
|
||||
#ifdef wxMOD_META
|
||||
if( wxmods & wxMOD_META )
|
||||
mods |= MD_META;
|
||||
#endif
|
||||
|
||||
#ifdef wxMOD_WIN
|
||||
if( wxmods & wxMOD_WIN )
|
||||
mods |= MD_SUPER;
|
||||
#endif
|
||||
|
||||
return mods;
|
||||
}
|
||||
/// Returns the state of key modifiers (Alt, Ctrl and so on) as OR'ed list
|
||||
/// of bits (MD_CTRL, MD_ALT ...)
|
||||
static int decodeModifiers( const wxKeyboardState* aState );
|
||||
|
||||
private:
|
||||
/// The time threshold for a mouse button press that distinguishes between a single mouse
|
||||
|
Loading…
x
Reference in New Issue
Block a user