Cancel selection if an item has been selected by right click

This commit is contained in:
Maciej Suminski 2017-07-31 10:17:37 +02:00
parent f303bf2999
commit 9cbcb3224c
1 changed files with 8 additions and 3 deletions

View File

@ -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 )