diff --git a/common/tool/selection_tool.cpp b/common/tool/selection_tool.cpp index d05fb79974..703b8c0f29 100644 --- a/common/tool/selection_tool.cpp +++ b/common/tool/selection_tool.cpp @@ -83,6 +83,12 @@ void SELECTION_TOOL::setModifiersState( bool aShiftState, bool aCtrlState, bool } +bool SELECTION_TOOL::hasModifier() +{ + return m_subtractive || m_additive || m_exclusive_or; +} + + int SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent ) { ACTION_MENU* actionMenu = aEvent.Parameter(); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index f470425035..9ffd0d60e8 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -344,8 +344,6 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ), evt->Modifier( MD_ALT ) ); - bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; - MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction(); EE_GRID_HELPER grid( m_toolMgr ); @@ -354,7 +352,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Avoid triggering when running under other tools // Distinguish point editor from selection modification by checking modifiers if( m_frame->ToolStackIsEmpty() && m_toolMgr->GetTool() - && ( !m_toolMgr->GetTool()->HasPoint() || modifier_enabled ) ) + && ( !m_toolMgr->GetTool()->HasPoint() || hasModifier() ) ) { m_originalCursor = m_toolMgr->GetMousePosition(); m_disambiguateTimer.StartOnce( 500 ); @@ -381,7 +379,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) CollectHits( collector, evt->Position() ); narrowSelection( collector, evt->Position(), false ); - if( collector.GetCount() == 1 && !m_isSymbolEditor && !modifier_enabled ) + if( collector.GetCount() == 1 && !m_isSymbolEditor && !hasModifier() ) { OPT_TOOL_EVENT autostart = autostartEvent( evt, grid, collector[0] ); @@ -498,7 +496,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( SCH_EDIT_FRAME* schframe = dynamic_cast( m_frame ) ) schframe->FocusOnItem( nullptr ); - if( modifier_enabled || drag_action == MOUSE_DRAG_ACTION::SELECT ) + if( hasModifier() || drag_action == MOUSE_DRAG_ACTION::SELECT ) { selectMultiple(); } @@ -611,7 +609,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { narrowSelection( collector, evt->Position(), false ); - if( collector.GetCount() == 1 && !modifier_enabled ) + if( collector.GetCount() == 1 && !hasModifier() ) { OPT_TOOL_EVENT autostartEvt = autostartEvent( evt, grid, collector[0] ); diff --git a/include/tool/selection_tool.h b/include/tool/selection_tool.h index 09f91f66d5..a5a2ffbdec 100644 --- a/include/tool/selection_tool.h +++ b/include/tool/selection_tool.h @@ -116,6 +116,11 @@ protected: */ void setModifiersState( bool aShiftState, bool aCtrlState, bool aAltState ); + /** + * True if a selection modifier is enabled, false otherwise. + */ + bool hasModifier(); + /** * Determines if ctrl-click is highlight net or XOR selection. */ diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index e67324d0c7..7883305671 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -89,8 +89,6 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ), evt->Modifier( MD_ALT ) ); - bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; - if( evt->IsMouseDown( BUT_LEFT ) ) { // Avoid triggering when running under other tools @@ -144,7 +142,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { m_disambiguateTimer.Stop(); - if( modifier_enabled || m_selection.Empty() ) + if( hasModifier() || m_selection.Empty() ) { selectMultiple(); } @@ -187,7 +185,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_frame->ToolStackIsEmpty() ) { - if( !modifier_enabled + if( !hasModifier() && !m_selection.Empty() && m_frame->GetDragAction() == MOUSE_DRAG_ACTION::DRAG_SELECTED && evt->HasPosition() diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index c6932018b2..c2e44e5693 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -272,7 +272,6 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ), evt->Modifier( MD_ALT ) ); - bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; PCB_BASE_FRAME* frame = getEditFrame(); bool brd_editor = frame && frame->IsType( FRAME_PCB_EDITOR ); ROUTER_TOOL* router = m_toolMgr->GetTool(); @@ -370,7 +369,7 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->FocusOnItem( nullptr ); m_toolMgr->ProcessEvent( EVENTS::InhibitSelectionEditing ); - if( modifier_enabled || dragAction == MOUSE_DRAG_ACTION::SELECT ) + if( hasModifier() || dragAction == MOUSE_DRAG_ACTION::SELECT ) { selectMultiple(); } @@ -477,7 +476,7 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_frame->ToolStackIsEmpty() ) { // move cursor prediction - if( !modifier_enabled + if( !hasModifier() && dragAction == MOUSE_DRAG_ACTION::DRAG_SELECTED && !m_selection.Empty() && evt->HasPosition()