From 208a8553a59f9f2d9b537a2d453ef6d83f009e8c Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 2 Jun 2019 11:12:11 +0100 Subject: [PATCH] pcbnew: Add context menu to measure tool Fixes: lp:1831063 * https://bugs.launchpad.net/kicad/+bug/1831063 --- pcbnew/tools/edit_tool.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 8c2cf8a44b..056d52e467 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -281,6 +281,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; } @@ -1279,7 +1294,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) else if( evt->IsClick( BUT_RIGHT ) ) { - m_menu.ShowContextMenu( selection() ); + m_menu.ShowContextMenu(); } }