diff --git a/pcbnew/dialogs/dialog_get_footprint.cpp b/pcbnew/dialogs/dialog_get_footprint.cpp
index 806e57407b..ddff9b0457 100644
--- a/pcbnew/dialogs/dialog_get_footprint.cpp
+++ b/pcbnew/dialogs/dialog_get_footprint.cpp
@@ -60,12 +60,20 @@ DIALOG_GET_FOOTPRINT::DIALOG_GET_FOOTPRINT( PCB_BASE_FRAME* parent, bool aShowBr
m_buttonBrowse->Show( aShowBrowseButton );
m_buttonBrowse->Enable( aShowBrowseButton );
+ m_sdbSizerOK->SetDefault();
+
m_textCmpNameCtrl->SetFocus();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
}
+void DIALOG_GET_FOOTPRINT::OnHistoryClick( wxCommandEvent& aEvent )
+{
+ m_textCmpNameCtrl->SetValue( m_historyList->GetStringSelection() );
+}
+
+
void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
{
m_selectionIsKeyword = false;
@@ -76,7 +84,10 @@ void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
break;
case wxID_OK:
- m_Text = m_textCmpNameCtrl->GetValue();
+ if( m_historyList->HasFocus() )
+ m_Text = m_historyList->GetStringSelection();
+ else
+ m_Text = m_textCmpNameCtrl->GetValue();
break;
case ID_ACCEPT_KEYWORD:
@@ -98,6 +109,7 @@ void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
m_Text.Trim( true ); // Remove blanks at end
// Put an wxID_OK event through the dialog infrastrucutre
+ aEvent.SetEventType( wxEVT_COMMAND_BUTTON_CLICKED );
aEvent.SetId( wxID_OK );
aEvent.Skip();
}
diff --git a/pcbnew/dialogs/dialog_get_footprint.h b/pcbnew/dialogs/dialog_get_footprint.h
index d5c869e7c0..f35cb98710 100644
--- a/pcbnew/dialogs/dialog_get_footprint.h
+++ b/pcbnew/dialogs/dialog_get_footprint.h
@@ -74,6 +74,7 @@ public:
void SetComponentName( const wxString& name );
private:
+ void OnHistoryClick( wxCommandEvent& aEvent ) override;
void Accept( wxCommandEvent& aEvent ) override;
};
diff --git a/pcbnew/dialogs/dialog_get_footprint_base.cpp b/pcbnew/dialogs/dialog_get_footprint_base.cpp
index 3ffad49f20..ed0fab19c7 100644
--- a/pcbnew/dialogs/dialog_get_footprint_base.cpp
+++ b/pcbnew/dialogs/dialog_get_footprint_base.cpp
@@ -79,7 +79,8 @@ DIALOG_GET_FOOTPRINT_BASE::DIALOG_GET_FOOTPRINT_BASE( wxWindow* parent, wxWindow
this->Centre( wxBOTH );
// Connect Events
- m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
+ m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::OnHistoryClick ), NULL, this );
+ m_historyList->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
m_buttonKW->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
m_buttonList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
@@ -89,7 +90,8 @@ DIALOG_GET_FOOTPRINT_BASE::DIALOG_GET_FOOTPRINT_BASE( wxWindow* parent, wxWindow
DIALOG_GET_FOOTPRINT_BASE::~DIALOG_GET_FOOTPRINT_BASE()
{
// Disconnect Events
- m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
+ m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::OnHistoryClick ), NULL, this );
+ m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
m_buttonKW->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
m_buttonList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
diff --git a/pcbnew/dialogs/dialog_get_footprint_base.fbp b/pcbnew/dialogs/dialog_get_footprint_base.fbp
index 98e0023796..d03a7d991b 100644
--- a/pcbnew/dialogs/dialog_get_footprint_base.fbp
+++ b/pcbnew/dialogs/dialog_get_footprint_base.fbp
@@ -439,8 +439,8 @@
- Accept
-
+ OnHistoryClick
+ Accept
diff --git a/pcbnew/dialogs/dialog_get_footprint_base.h b/pcbnew/dialogs/dialog_get_footprint_base.h
index 764298381a..3034376d42 100644
--- a/pcbnew/dialogs/dialog_get_footprint_base.h
+++ b/pcbnew/dialogs/dialog_get_footprint_base.h
@@ -53,6 +53,7 @@ class DIALOG_GET_FOOTPRINT_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
+ virtual void OnHistoryClick( wxCommandEvent& event ) { event.Skip(); }
virtual void Accept( wxCommandEvent& event ) { event.Skip(); }