diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index ecb8927609..177146de6e 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -613,7 +613,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& even else if( fieldNdx == FOOTPRINT ) { // pick a footprint using the footprint picker. - wxString fpid; + wxString fpid = fieldValueTextCtrl->GetValue(); KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true, this ); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 9426c4714c..72dc717cc1 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -622,6 +622,24 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event ) } +bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aResultantFocusWindow ) +{ + if( aFootprint ) + { + LIB_ID fpid( *aFootprint ); + if( fpid.IsValid() ) + { + setCurNickname( fpid.GetLibNickname() ); + setCurFootprintName( fpid.GetLibItemName() ); + ReCreateFootprintList(); + SelectAndViewFootprint( NEW_PART ); + } + } + + return KIWAY_PLAYER::ShowModal( aFootprint, aResultantFocusWindow ); +} + + bool FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) { bool eventHandled = true; diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 40f4549397..4081b8bdd2 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -64,6 +64,15 @@ public: */ void ReCreateLibraryList(); + /** + * Function ShowModal + * + * Runs the Footprint Viewer as a modal dialog. + * @param aFootprint an optional FPID string to initialize the viewer with and to + * return a selected footprint through. + */ + bool ShowModal( wxString* aFootprint, wxWindow* aResultantFocusWindow ) override; + private: wxListBox* m_libList; // The list of libs names