diff --git a/common/dialogs/eda_view_switcher.cpp b/common/dialogs/eda_view_switcher.cpp index 2e1c0d0307..313c237c81 100644 --- a/common/dialogs/eda_view_switcher.cpp +++ b/common/dialogs/eda_view_switcher.cpp @@ -37,7 +37,7 @@ EDA_VIEW_SWITCHER::EDA_VIEW_SWITCHER( wxWindow* aParent, const wxArrayString& aItems ) : EDA_VIEW_SWITCHER_BASE( aParent ), m_tabState( true ), - m_receivingEvents( true ) + m_receivingEvents( false ) { m_listBox->InsertItems( aItems, 0 ); m_listBox->SetSelection( std::min( 1, (int) m_listBox->GetCount() - 1 ) ); @@ -63,6 +63,20 @@ EDA_VIEW_SWITCHER::EDA_VIEW_SWITCHER( wxWindow* aParent, const wxArrayString& aI } +bool EDA_VIEW_SWITCHER::Show( bool aShow ) +{ + if( !aShow ) + m_receivingEvents = false; + + bool ret = DIALOG_SHIM::Show( aShow ); + + if( aShow ) + m_receivingEvents = true; + + return ret; +} + + // OK, this is *really* annoying, but wxWidgets doesn't give us key-down events while the // control key is being held down. So we can't use OnKeyDown() or OnCharHook() and instead // must rely on watching key states in TryBefore(). @@ -79,13 +93,6 @@ bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent ) return DIALOG_SHIM::TryBefore( aEvent ); } - if( !wxGetKeyState( WXK_RAW_CONTROL ) ) - { - m_receivingEvents = false; - EndModal( wxID_OK ); - return true; - } - // Check for tab key leading edge if( !m_tabState && wxGetKeyState( WXK_TAB ) ) { @@ -117,5 +124,11 @@ bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent ) m_tabState = false; } + // Check for control key trailing edge + if( !wxGetKeyState( WXK_RAW_CONTROL ) ) + { + EndModal( wxID_OK ); + } + return DIALOG_SHIM::TryBefore( aEvent ); } diff --git a/common/dialogs/eda_view_switcher.h b/common/dialogs/eda_view_switcher.h index 8b6514fbd4..317fa410c3 100644 --- a/common/dialogs/eda_view_switcher.h +++ b/common/dialogs/eda_view_switcher.h @@ -35,6 +35,7 @@ public: protected: bool TryBefore( wxEvent& aEvent ) override; + bool Show( bool show ) override; protected: bool m_tabState;