From 1a7152d3eb99ed9a1f7d250e43dbcb1f25e62899 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 15 Feb 2024 18:06:54 +0000 Subject: [PATCH] Warp after context menu only if actively drawing. Fixes https://gitlab.com/kicad/code/kicad/-/issues/11080 --- pcbnew/tools/drawing_tool.cpp | 15 +++++++++++++++ pcbnew/tools/edit_tool_move_fct.cpp | 4 ++++ pcbnew/tools/pcb_selection_tool.cpp | 3 +++ 3 files changed, 22 insertions(+) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 94fcbdac1e..843b639bd3 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -882,6 +882,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_RIGHT ) ) { + if( !text ) + m_toolMgr->VetoContextMenuMouseWarp(); + m_menu.ShowContextMenu( selection() ); } else if( evt->IsClick( BUT_LEFT ) ) @@ -1179,6 +1182,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_RIGHT ) ) { + if( !dimension ) + m_toolMgr->VetoContextMenuMouseWarp(); + m_menu.ShowContextMenu( selection() ); } else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) @@ -1976,6 +1982,9 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, } else if( evt->IsClick( BUT_RIGHT ) ) { + if( !graphic ) + m_toolMgr->VetoContextMenuMouseWarp(); + m_menu.ShowContextMenu( selection() ); } else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) @@ -2411,6 +2420,9 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, } else if( evt->IsClick( BUT_RIGHT ) ) { + if( !graphic ) + m_toolMgr->VetoContextMenuMouseWarp(); + m_menu.ShowContextMenu( selection() ); } else if( evt->IsAction( &PCB_ACTIONS::incWidth ) ) @@ -2663,6 +2675,9 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) } else if( evt->IsClick( BUT_RIGHT ) ) { + if( !started ) + m_toolMgr->VetoContextMenuMouseWarp(); + m_menu.ShowContextMenu( selection() ); } // events that lock in nodes diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index 5ce316dff0..da911ebe06 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -675,6 +675,10 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit restore_state = true; // Canceling the tool means that items have to be restored break; // Finish } + else if( evt->IsClick( BUT_RIGHT ) ) + { + m_menu.ShowContextMenu( selection ); + } else if( evt->IsAction( &ACTIONS::undo ) || evt->IsAction( &ACTIONS::doDelete ) ) { restore_state = true; // Perform undo locally diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 850d9aaaa6..4c9e11336c 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -348,7 +348,10 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->ForceRefresh(); if( !selectionCancelled ) + { + m_toolMgr->VetoContextMenuMouseWarp(); m_menu.ShowContextMenu( m_selection ); + } } else if( evt->IsDblClick( BUT_LEFT ) ) {