From 2306d00c8905be699528efe7759ec2e9371995cb Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 13 Jan 2022 22:28:45 -0500 Subject: [PATCH] Do not check key states for non-key events in TryBefore Fixes https://gitlab.com/kicad/code/kicad/-/issues/10127 --- pcbnew/pcb_base_edit_frame.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index fa35480338..40fe82dbcf 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -96,23 +96,26 @@ bool PCB_BASE_EDIT_FRAME::TryBefore( wxEvent& aEvent ) { static bool s_switcherShown = false; - if( !s_switcherShown && wxGetKeyState( WXK_RAW_CONTROL ) && wxGetKeyState( WXK_TAB ) ) + if( aEvent.GetEventType() == wxEVT_CHAR || aEvent.GetEventType() == wxEVT_CHAR_HOOK ) { - if( m_appearancePanel && this->IsActive() ) + if( !s_switcherShown && wxGetKeyState( WXK_RAW_CONTROL ) && wxGetKeyState( WXK_TAB ) ) { - const wxArrayString& mru = m_appearancePanel->GetLayerPresetsMRU(); - EDA_VIEW_SWITCHER switcher( this, mru ); + if( m_appearancePanel && this->IsActive() ) + { + const wxArrayString& mru = m_appearancePanel->GetLayerPresetsMRU(); + EDA_VIEW_SWITCHER switcher( this, mru ); - s_switcherShown = true; - switcher.ShowModal(); - s_switcherShown = false; + s_switcherShown = true; + switcher.ShowModal(); + s_switcherShown = false; - int idx = switcher.GetSelection(); + int idx = switcher.GetSelection(); - if( idx >= 0 && idx < (int) mru.size() ) - m_appearancePanel->ApplyLayerPreset( mru[idx] ); + if( idx >= 0 && idx < (int) mru.size() ) + m_appearancePanel->ApplyLayerPreset( mru[idx] ); - return true; + return true; + } } }