diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 60e9267053..1c64d685ee 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -634,4 +634,6 @@ const TOOL_EVENT EVENTS::ClearedEvent( TC_MESSAGE, TA_ACTION, "common.Interactiv const TOOL_EVENT EVENTS::SelectedItemsModified( TC_MESSAGE, TA_ACTION, "common.Interactive.modified" ); const TOOL_EVENT EVENTS::SelectedItemsMoved( TC_MESSAGE, TA_ACTION, "common.Interactive.moved" ); +const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.inhibit" ); +const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.uninhibit" ); diff --git a/include/tool/actions.h b/include/tool/actions.h index 84978096d8..f3e6d9649e 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -214,6 +214,10 @@ public: //< Selected items were moved, this can be very high frequency on the canvas, use with care const static TOOL_EVENT SelectedItemsMoved; + + ///> Used to inform tools that the selection should temporarily be non-editable + const static TOOL_EVENT InhibitSelectionEditing; + const static TOOL_EVENT UninhibitSelectionEditing; }; #endif // __ACTIONS_H diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 43a945e84f..a04943030d 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -394,7 +394,7 @@ void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent ) int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) { - if( !m_selectionTool ) + if( !m_selectionTool || aEvent.Matches( EVENTS::InhibitSelectionEditing ) ) return 0; const PCBNEW_SELECTION& selection = m_selectionTool->GetSelection(); @@ -439,7 +439,8 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( editFrame->IsGridVisible() ); - if( !m_editPoints || evt->IsSelectionEvent() ) + if( !m_editPoints || evt->IsSelectionEvent() || + evt->Matches( EVENTS::InhibitSelectionEditing ) ) break; EDIT_POINT* prevHover = m_hoveredPoint; @@ -2148,4 +2149,6 @@ void POINT_EDITOR::setTransitions() Go( &POINT_EDITOR::OnSelectionChange, EVENTS::SelectedEvent ); Go( &POINT_EDITOR::OnSelectionChange, EVENTS::UnselectedEvent ); Go( &POINT_EDITOR::changeEditMethod, ACTIONS::changeEditMethod.MakeEvent() ); + Go( &POINT_EDITOR::OnSelectionChange, EVENTS::InhibitSelectionEditing ); + Go( &POINT_EDITOR::OnSelectionChange, EVENTS::UninhibitSelectionEditing ); } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 5fec4c2aad..8e4fce343e 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -285,6 +285,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->IsDrag( BUT_LEFT ) ) { m_frame->FocusOnItem( nullptr ); + m_toolMgr->ProcessEvent( EVENTS::InhibitSelectionEditing ); if( modifier_enabled || dragAlwaysSelects ) { @@ -756,6 +757,8 @@ bool SELECTION_TOOL::selectMultiple() if( !cancelled ) m_selection.ClearReferencePoint(); + m_toolMgr->ProcessEvent( EVENTS::UninhibitSelectionEditing ); + return cancelled; }