From 79d062aefcdeda4305e50a595e69dfca33bbee06 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 30 Aug 2019 10:32:43 +0100 Subject: [PATCH] Don't allow selection dragging when a picker tool is running. Fixes: lp:1841691 * https://bugs.launchpad.net/kicad/+bug/1841691 --- common/tool/picker_tool.cpp | 51 ++++++++++++++++------------- pcbnew/tools/pcbnew_picker_tool.cpp | 47 ++++++++++++++------------ 2 files changed, 55 insertions(+), 43 deletions(-) diff --git a/common/tool/picker_tool.cpp b/common/tool/picker_tool.cpp index e0f43216c8..d64d79fb9a 100644 --- a/common/tool/picker_tool.cpp +++ b/common/tool/picker_tool.cpp @@ -71,7 +71,31 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( m_cursor ); VECTOR2D cursorPos = controls->GetCursorPosition( snap && !evt->Modifier( MD_ALT ) ); - if( evt->IsClick( BUT_LEFT ) ) + if( evt->IsCancelInteractive() || evt->IsActivate() ) + { + if( m_cancelHandler ) + { + try + { + (*m_cancelHandler)(); + } + catch( std::exception& e ) + { + std::cerr << "PICKER_TOOL cancel handler error: " << e.what() << std::endl; + } + } + + // Activating a new tool may have alternate finalization from canceling the current + // tool + if( evt->IsActivate() ) + finalize_state = END_ACTIVATE; + else + finalize_state = EVT_CANCEL; + + break; + } + + else if( evt->IsClick( BUT_LEFT ) ) { bool getNext = false; @@ -115,33 +139,16 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) } } - else if( evt->IsCancelInteractive() || evt->IsActivate() ) + else if( evt->IsDblClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) ) { - if( m_cancelHandler ) - { - try - { - (*m_cancelHandler)(); - } - catch( std::exception& e ) - { - std::cerr << "PICKER_TOOL cancel handler error: " << e.what() << std::endl; - } - } - - // Activating a new tool may have alternate finalization from canceling the current - // tool - if( evt->IsActivate() ) - finalize_state = END_ACTIVATE; - else - finalize_state = EVT_CANCEL; - - break; + // Not currently used, but we don't want to pass them either } + else if( evt->IsClick( BUT_RIGHT ) ) { m_menu.ShowContextMenu(); } + else evt->SetPassEvent(); } diff --git a/pcbnew/tools/pcbnew_picker_tool.cpp b/pcbnew/tools/pcbnew_picker_tool.cpp index c8dfbd1e30..30b1a7ffde 100644 --- a/pcbnew/tools/pcbnew_picker_tool.cpp +++ b/pcbnew/tools/pcbnew_picker_tool.cpp @@ -59,7 +59,30 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr ); controls->ForceCursorPosition(true, cursorPos ); - if( evt->IsClick( BUT_LEFT ) ) + if( evt->IsCancelInteractive() || evt->IsActivate() ) + { + if( m_cancelHandler ) + { + try + { + (*m_cancelHandler)(); + } + catch( std::exception& e ) + { + std::cerr << "PCBNEW_PICKER_TOOL cancelHandler error: " << e.what() << std::endl; + } + } + + // Activating a new tool may have alternate finalization from canceling the current tool + if( evt->IsActivate() ) + finalize_state = END_ACTIVATE; + else + finalize_state = EVT_CANCEL; + + break; + } + + else if( evt->IsClick( BUT_LEFT ) ) { bool getNext = false; @@ -103,27 +126,9 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) } } - else if( evt->IsCancelInteractive() || evt->IsActivate() ) + else if( evt->IsDblClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) ) { - if( m_cancelHandler ) - { - try - { - (*m_cancelHandler)(); - } - catch( std::exception& e ) - { - std::cerr << "PCBNEW_PICKER_TOOL cancelHandler error: " << e.what() << std::endl; - } - } - - // Activating a new tool may have alternate finalization from canceling the current tool - if( evt->IsActivate() ) - finalize_state = END_ACTIVATE; - else - finalize_state = EVT_CANCEL; - - break; + // Not currently used, but we don't want to pass them either } else if( evt->IsClick( BUT_RIGHT ) )