From 006d7ddd310d3d9769dce0871fb83e21bdf3fc0f Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 2 Jun 2019 11:15:54 +0100 Subject: [PATCH] pcbnew: Add context menu for measure tool Fixes: lp:1831063 * https://bugs.launchpad.net/kicad/+bug/1831063 --- pcbnew/tools/edit_tool.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 0685bfff25..c9aa312036 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -290,6 +290,21 @@ bool EDIT_TOOL::Init() menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition ); menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition ); + // Populate the context menu displayed during the edit tool (primarily the measure tool) + auto activeToolCondition = [ this ] ( const SELECTION& aSel ) { + return ( frame()->GetToolId() != ID_NO_TOOL_SELECTED ); + }; + + auto frame = getEditFrame(); + auto& ctxMenu = m_menu.GetMenu(); + + // "Cancel" goes at the top of the context menu when a tool is active + ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1000 ); + ctxMenu.AddSeparator( activeToolCondition, 1000 ); + + if( frame ) + m_menu.AddStandardSubMenus( *frame ); + return true; }