From 1138c32bf3c2bc157f8f49cea69665879dd0c8f8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 25 Aug 2020 12:53:39 +0100 Subject: [PATCH] Don't pass Cancel event where there was a specific action cancelled. For instance, if during a move the user hits ESC they only want the move cancelled, not (for instance) the selection dropped. Fixes https://gitlab.com/kicad/code/kicad/issues/5356 --- common/tool/picker_tool.cpp | 5 +++++ eeschema/tools/lib_move_tool.cpp | 3 +++ eeschema/tools/sch_move_tool.cpp | 3 +++ include/tool/tool_event.h | 2 +- pagelayout_editor/tools/pl_edit_tool.cpp | 3 +++ pcbnew/tools/edit_tool.cpp | 3 +++ 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/common/tool/picker_tool.cpp b/common/tool/picker_tool.cpp index 069ea3fcfd..9a39ab86a5 100644 --- a/common/tool/picker_tool.cpp +++ b/common/tool/picker_tool.cpp @@ -88,9 +88,14 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) // Activating a new tool may have alternate finalization from canceling the current // tool if( evt->IsActivate() ) + { finalize_state = END_ACTIVATE; + } else + { + evt->SetPassEvent( false ); finalize_state = EVT_CANCEL; + } break; } diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index 096375298e..d4e94198d6 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -204,7 +204,10 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->IsCancelInteractive() || evt->IsActivate() ) { if( m_moveInProgress ) + { + evt->SetPassEvent( false ); restore_state = true; + } break; } diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 6a77c56e89..cc8d916644 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -352,7 +352,10 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->IsCancelInteractive() ) { if( m_moveInProgress ) + { + evt->SetPassEvent( false ); restore_state = true; + } break; } diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index fe24587f89..b13f78eb64 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -253,7 +253,7 @@ public: ///> be passed on to subsequent tools on the stack. Defaults to true for TC_MESSAGES; false ///> for everything else. bool PassEvent() const { return m_passEvent; } - void SetPassEvent() { m_passEvent = true; } + void SetPassEvent( bool aPass = true ) { m_passEvent = aPass; } ///> Returns if it this event has a valid position (true for mouse events and context-menu ///> or hotkey-based command events) diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index f28f1b9e35..03b5f6d079 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -192,7 +192,10 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->IsCancelInteractive() || evt->IsActivate() ) { if( m_moveInProgress ) + { + evt->SetPassEvent( false ); restore_state = true; + } break; } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 0530ca3256..58f35cef64 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -573,6 +573,9 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) else if( evt->IsCancelInteractive() || evt->IsActivate() ) { + if( m_dragging && evt->IsCancelInteractive() ) + evt->SetPassEvent( false ); + restore_state = true; // Canceling the tool means that items have to be restored break; // Finish }