diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index da9d58b125..8fbfc81906 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -96,6 +96,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectGrid ) EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectZoom ) + EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton ) // listbox events EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList ) @@ -479,7 +480,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& event ) Close( true ); } - else + else if( GetBoard()->m_Modules ) { PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false ); @@ -608,6 +609,12 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event ) } +void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent ) +{ + aEvent.Enable( GetBoard()->m_Modules != nullptr ); +} + + bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent ) { if( aFootprint && !aFootprint->IsEmpty() ) diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index b746c4ddc6..3bf3ea117e 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -75,6 +75,11 @@ public: */ void ReCreateLibraryList(); + /** + * Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar + */ + void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent ); + /** * Function ShowModal *