Try and reduce opportunity for lost keystrokes.

Fixes https://gitlab.com/kicad/code/kicad/issues/12445

(cherry picked from commit d2712bac37)
This commit is contained in:
Jeff Young 2022-09-18 11:27:14 +01:00
parent 8b690c9a3c
commit 1a2e2bd29a
2 changed files with 24 additions and 4 deletions

View File

@ -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();
if( searchCtrlHasFocus )
{
m_tcFilterString->SetFocus();
m_tcFilterString->SetInsertionPoint( pos );
}
}

View File

@ -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;
};