From 9cbcb3224c99a47641d49e128d3839dd3fb1118f Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 31 Jul 2017 10:17:37 +0200 Subject: [PATCH] Cancel selection if an item has been selected by right click --- pcbnew/tools/selection_tool.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 717653312b..69827503eb 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -232,6 +232,8 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason ) int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { + bool unselect = false; + // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { @@ -265,9 +267,9 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // right click? if there is any object - show the context menu else if( evt->IsClick( BUT_RIGHT ) ) { - bool emptySelection = m_selection.Empty(); + unselect = m_selection.Empty(); - if( emptySelection ) + if( unselect ) selectPoint( evt->Position() ); m_menu.ShowContextMenu( m_selection ); @@ -301,6 +303,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else { m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" ); + unselect = true; } } @@ -320,9 +323,11 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) } } - else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE ) + else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE + || ( unselect && m_toolMgr->GetCurrentToolId() == GetId() ) ) { clearSelection(); + unselect = false; } else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )