7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 11:21:41 +00:00

Pcbnew: get footprint by name dialog: focus the item in the dropdown on typing

It's not a complete UI for this dialog (especially as the comments
around m_multipleHint->Show( false ) indicate the intent was to
have a multi-selection ability here, but at least there's a way to
confirm what you're about to pick up.
This commit is contained in:
John Beard 2024-11-01 20:37:17 +08:00
parent c39573ace3
commit 1450af7d30
4 changed files with 33 additions and 6 deletions

View File

@ -52,11 +52,34 @@ wxString DIALOG_GET_FOOTPRINT_BY_NAME::GetValue() const
}
static wxString GetFootprintName( const wxString& aOptionCtrlString )
{
return aOptionCtrlString.BeforeFirst( ' ' );
}
void DIALOG_GET_FOOTPRINT_BY_NAME::OnSelectFootprint( wxCommandEvent& aEvent )
{
if( m_choiceFpList->GetSelection() >= 0 )
const int selection = m_choiceFpList->GetSelection();
if( selection >= 0 )
{
m_SearchTextCtrl->SetValue(
m_choiceFpList->GetString( m_choiceFpList->GetSelection() ).BeforeFirst( ' ' ) );
m_SearchTextCtrl->SetValue( GetFootprintName( m_choiceFpList->GetString( selection ) ) );
}
}
void DIALOG_GET_FOOTPRINT_BY_NAME::OnSearchInputChanged( wxCommandEvent& event )
{
// Find the matching footprint in the list if there is one
const wxString entry = m_SearchTextCtrl->GetValue().Trim( true ).Trim( false );
for( unsigned ii = 0; ii < m_choiceFpList->GetCount(); ++ii )
{
if( GetFootprintName( m_choiceFpList->GetString( ii ) ).IsSameAs( entry, false ) )
{
m_choiceFpList->SetSelection( ii );
return;
}
}
m_choiceFpList->SetSelection( -1 );
}

View File

@ -44,4 +44,6 @@ public:
private:
// Called when selecting an item from the item list
void OnSelectFootprint( wxCommandEvent& aEvent ) override;
void OnSearchInputChanged( wxCommandEvent& event ) override;
};

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -69,6 +69,7 @@ DIALOG_GET_FOOTPRINT_BY_NAME_BASE::DIALOG_GET_FOOTPRINT_BY_NAME_BASE( wxWindow*
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::onClose ) );
m_SearchTextCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::OnSearchInputChanged ), NULL, this );
m_choiceFpList->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::OnSelectFootprint ), NULL, this );
}
@ -76,6 +77,7 @@ DIALOG_GET_FOOTPRINT_BY_NAME_BASE::~DIALOG_GET_FOOTPRINT_BY_NAME_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::onClose ) );
m_SearchTextCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::OnSearchInputChanged ), NULL, this );
m_choiceFpList->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BY_NAME_BASE::OnSelectFootprint ), NULL, this );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -26,7 +26,6 @@
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_GET_FOOTPRINT_BY_NAME_BASE
///////////////////////////////////////////////////////////////////////////////
@ -46,6 +45,7 @@ class DIALOG_GET_FOOTPRINT_BY_NAME_BASE : public DIALOG_SHIM
// Virtual event handlers, override them in your derived class
virtual void onClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnSearchInputChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSelectFootprint( wxCommandEvent& event ) { event.Skip(); }