diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index ca20e0e3e6..3f8bfe3b53 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -421,8 +421,22 @@ void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent ) // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list // of available footprints which match the filter - // GTK loses the search-control's focus when updating the footprints list box, so we record - // the insertion point here and then restore it (and the focus) at the end. + if( !m_footprintListPendingUpdate ) + { + Bind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintListOnIdle, this ); + m_footprintListPendingUpdate = true; + } +} + + +void CVPCB_MAINFRAME::updateFootprintListOnIdle( wxIdleEvent& aEvent ) +{ + Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintListOnIdle, this ); + m_footprintListPendingUpdate = false; + + // GTK loses the search-control's focus on a Refresh event, so we record the focus and + // insertion point here and then restore them at the end. + bool searchCtrlHasFocus = m_tcFilterString->HasFocus(); long pos = m_tcFilterString->GetInsertionPoint(); COMPONENT* symbol = GetSelectedComponent(); @@ -440,8 +454,11 @@ void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent ) DisplayStatus(); - m_tcFilterString->SetFocus(); - m_tcFilterString->SetInsertionPoint( pos ); + if( searchCtrlHasFocus ) + { + m_tcFilterString->SetFocus(); + m_tcFilterString->SetInsertionPoint( pos ); + } } diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 320ff379b1..c81e307352 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -357,6 +357,8 @@ private: void updateFootprintViewerOnIdle( wxIdleEvent& aEvent ); + void updateFootprintListOnIdle( wxIdleEvent& aEvent ); + /** * Read the .equ files and populate the list of equivalents. * @@ -407,6 +409,7 @@ private: CVPCB_UNDO_REDO_LIST m_undoList; CVPCB_UNDO_REDO_LIST m_redoList; + bool m_footprintListPendingUpdate; bool m_viewerPendingUpdate; };