diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 43ca40b670..0b39a6e720 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -958,12 +958,14 @@ void FOOTPRINT_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new MODULE_EDITOR_TOOLS ); m_toolManager->RegisterTool( new PLACEMENT_TOOL ); m_toolManager->RegisterTool( new PICKER_TOOL ); - m_toolManager->InitTools(); + m_toolManager->GetTool()->SetEditModules( true ); m_toolManager->GetTool()->SetEditModules( true ); m_toolManager->GetTool()->SetEditModules( true ); m_toolManager->GetTool()->SetEditModules( true ); + m_toolManager->InitTools(); + m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); } diff --git a/pcbnew/tools/module_editor_tools.cpp b/pcbnew/tools/module_editor_tools.cpp index ab0c28535d..43904fbda2 100644 --- a/pcbnew/tools/module_editor_tools.cpp +++ b/pcbnew/tools/module_editor_tools.cpp @@ -87,23 +87,6 @@ void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason ) } -bool MODULE_EDITOR_TOOLS::Init() -{ - // Find the selection tool, so they can cooperate - SELECTION_TOOL* selectionTool = m_toolMgr->GetTool(); - - if( !selectionTool ) - { - DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) ); - return false; - } - - selectionTool->GetToolMenu().GetMenu().AddItem( COMMON_ACTIONS::enumeratePads ); - - return true; -} - - int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); diff --git a/pcbnew/tools/module_editor_tools.h b/pcbnew/tools/module_editor_tools.h index 1435609882..68391c2e48 100644 --- a/pcbnew/tools/module_editor_tools.h +++ b/pcbnew/tools/module_editor_tools.h @@ -50,9 +50,6 @@ public: /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; - /// @copydoc TOOL_INTERACTIVE::Init() - bool Init() override; - /** * Function PlacePad() * Places a pad in module editor. diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 19236aa156..289249948f 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -47,7 +47,9 @@ public: using SHOW_FUNCTOR = std::function; - PAD_CONTEXT_MENU( SHOW_FUNCTOR aHaveGlobalPadSetting): + PAD_CONTEXT_MENU( bool aEditingFootprint, + SHOW_FUNCTOR aHaveGlobalPadSetting ): + m_editingFootprint( aEditingFootprint ), m_haveGlobalPadSettings( aHaveGlobalPadSetting ) { SetIcon( pad_xpm ); @@ -56,13 +58,21 @@ public: Add( COMMON_ACTIONS::copyPadSettings ); Add( COMMON_ACTIONS::applyPadSettings ); Add( COMMON_ACTIONS::pushPadSettings ); + + // show modedit-specific items + if( m_editingFootprint ) + { + AppendSeparator(); + + Add( COMMON_ACTIONS::enumeratePads ); + } } protected: CONTEXT_MENU* create() const override { - return new PAD_CONTEXT_MENU( m_haveGlobalPadSettings ); + return new PAD_CONTEXT_MENU( m_editingFootprint, m_haveGlobalPadSettings ); } private: @@ -111,6 +121,7 @@ private: Enable( getMenuId( COMMON_ACTIONS::pushPadSettings ), enablements.canPush ); } + bool m_editingFootprint; SHOW_FUNCTOR m_haveGlobalPadSettings; }; @@ -152,7 +163,8 @@ bool PAD_TOOL::Init() return hasMasterPadSettings(); }; - auto contextMenu = std::make_shared( haveMasterPad ); + auto contextMenu = std::make_shared( + EditingModules(), haveMasterPad ); contextMenu->SetTool( this ); SELECTION_TOOL* selTool = m_toolMgr->GetTool();