Attempt to de-bounce EndModal() on GTK.

This commit is contained in:
Jeff Young 2020-08-19 13:12:48 +01:00
parent 249de20c6b
commit d3d90ddb67
2 changed files with 17 additions and 7 deletions

View File

@ -31,7 +31,8 @@
EDA_VIEW_SWITCHER::EDA_VIEW_SWITCHER( wxWindow* aParent, const wxArrayString& aItems ) : EDA_VIEW_SWITCHER::EDA_VIEW_SWITCHER( wxWindow* aParent, const wxArrayString& aItems ) :
EDA_VIEW_SWITCHER_BASE( aParent ), EDA_VIEW_SWITCHER_BASE( aParent ),
m_tabState( true ) m_tabState( true ),
m_receivingEvents( true )
{ {
m_listBox->InsertItems( aItems, 0 ); m_listBox->InsertItems( aItems, 0 );
m_listBox->SetSelection( std::min( 1, (int) m_listBox->GetCount() - 1 ) ); m_listBox->SetSelection( std::min( 1, (int) m_listBox->GetCount() - 1 ) );
@ -68,18 +69,20 @@ EDA_VIEW_SWITCHER::EDA_VIEW_SWITCHER( wxWindow* aParent, const wxArrayString& aI
// //
bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent ) bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent )
{ {
if( !m_receivingEvents )
{
return DIALOG_SHIM::TryBefore( aEvent );
}
if( !wxGetKeyState( WXK_RAW_CONTROL ) ) if( !wxGetKeyState( WXK_RAW_CONTROL ) )
{ {
m_receivingEvents = false;
EndModal( wxID_OK ); EndModal( wxID_OK );
return true; return true;
} }
if( m_tabState ) // Check for tab key leading edge
{ if( !m_tabState && wxGetKeyState( WXK_TAB ) )
if( !wxGetKeyState( WXK_TAB ) )
m_tabState = false;
}
else if( wxGetKeyState( WXK_TAB ) )
{ {
m_tabState = true; m_tabState = true;
@ -103,5 +106,11 @@ bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent )
return true; return true;
} }
// Check for tab key trailing edge
if( m_tabState && !wxGetKeyState( WXK_TAB ) )
{
m_tabState = false;
}
return DIALOG_SHIM::TryBefore( aEvent ); return DIALOG_SHIM::TryBefore( aEvent );
} }

View File

@ -38,6 +38,7 @@ protected:
protected: protected:
bool m_tabState; bool m_tabState;
bool m_receivingEvents;
}; };
#endif // EDA_VIEW_SWITCHER_H #endif // EDA_VIEW_SWITCHER_H