diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index f93b3c18c3..a8ac70c94d 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -429,8 +429,22 @@ void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event ) // 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(); @@ -448,8 +462,11 @@ void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event ) 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 bd4c5144fa..3681207834 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -345,6 +345,8 @@ private: void updateFootprintViewerOnIdle( wxIdleEvent& aEvent ); + void updateFootprintListOnIdle( wxIdleEvent& aEvent ); + /** * Read the .equ files and populate the list of equivalents. * @@ -394,6 +396,7 @@ private: CVPCB_UNDO_REDO_LIST m_undoList; CVPCB_UNDO_REDO_LIST m_redoList; + bool m_footprintListPendingUpdate; bool m_viewerPendingUpdate; };