diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 14b9c5af96..b0ee6d9c19 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1780,6 +1780,7 @@ int SCH_EDIT_TOOL::InteractiveDelete( const TOOL_EVENT& aEvent ) picker->SetCursor( KICURSOR::REMOVE ); picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this]( const VECTOR2D& aPosition ) -> bool diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 94f112a245..a05977c026 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -558,6 +558,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) picker->SetCursor( KICURSOR::VOLTAGE_PROBE ); picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this, simFrame]( const VECTOR2D& aPosition ) @@ -724,6 +725,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent ) picker->SetCursor( KICURSOR::TUNE ); picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this]( const VECTOR2D& aPosition ) @@ -1251,6 +1253,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) picker->SetCursor( KICURSOR::BULLSEYE ); picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this] ( const VECTOR2D& aPos ) diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 041450966c..6c5147e556 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -497,6 +497,8 @@ int SYMBOL_EDITOR_EDIT_TOOL::InteractiveDelete( const TOOL_EVENT& aEvent ) Activate(); picker->SetCursor( KICURSOR::REMOVE ); + picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this]( const VECTOR2D& aPosition ) -> bool diff --git a/include/tool/picker_tool.h b/include/tool/picker_tool.h index d3bdc762aa..c50ec28864 100644 --- a/include/tool/picker_tool.h +++ b/include/tool/picker_tool.h @@ -65,6 +65,14 @@ public: inline void SetSnapping( bool aSnap ) { m_snap = aSnap; } + void ClearHandlers() + { + m_clickHandler.reset(); + m_motionHandler.reset(); + m_cancelHandler.reset(); + m_finalizeHandler.reset(); + } + /** * Set a handler for mouse click event. * diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index 38391e202b..501b1c8838 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -216,9 +216,9 @@ void DIALOG_POSITION_RELATIVE::OnSelectItemClick( wxCommandEvent& event ) PCB_PICKER_TOOL* pickerTool = m_toolMgr->GetTool(); wxCHECK( pickerTool, /* void */ ); - m_toolMgr->RunAction( - PCB_ACTIONS::selectItemInteractively, - PCB_PICKER_TOOL::INTERACTIVE_PARAMS{ this, _( "Select reference item..." ) } ); + + m_toolMgr->RunAction( PCB_ACTIONS::selectItemInteractively, + PCB_PICKER_TOOL::INTERACTIVE_PARAMS{ this, _( "Select reference item..." ) } ); Hide(); } @@ -230,9 +230,9 @@ void DIALOG_POSITION_RELATIVE::OnSelectPointClick( wxCommandEvent& event ) PCB_PICKER_TOOL* pickerTool = m_toolMgr->GetTool(); wxCHECK( pickerTool, /* void */ ); - m_toolMgr->RunAction( - PCB_ACTIONS::selectPointInteractively, - PCB_PICKER_TOOL::INTERACTIVE_PARAMS{ this, _( "Select reference point..." ) } ); + + m_toolMgr->RunAction( PCB_ACTIONS::selectPointInteractively, + PCB_PICKER_TOOL::INTERACTIVE_PARAMS{ this, _( "Select reference point..." ) } ); Hide(); } diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 8e8f50f6d0..ab0af98b41 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -1759,6 +1759,9 @@ int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); + picker->SetCursor( KICURSOR::PLACE ); + picker->ClearHandlers(); + picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool { @@ -1798,11 +1801,8 @@ void BOARD_EDITOR_CONTROL::setTransitions() Go( &BOARD_EDITOR_CONTROL::ImportSpecctraSession, PCB_ACTIONS::importSpecctraSession.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::ExportSpecctraDSN, PCB_ACTIONS::exportSpecctraDSN.MakeEvent() ); - if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame - && m_frame->GetExportNetlistAction() ) - { + if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame && m_frame->GetExportNetlistAction() ) Go( &BOARD_EDITOR_CONTROL::ExportNetlist, m_frame->GetExportNetlistAction()->MakeEvent() ); - } Go( &BOARD_EDITOR_CONTROL::GenerateDrillFiles, PCB_ACTIONS::generateDrillFiles.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::GenerateGerbers, PCB_ACTIONS::generateGerbers.MakeEvent() ); diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index e6892fa00a..3d9178964d 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -1954,6 +1954,8 @@ int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) Activate(); picker->SetCursor( KICURSOR::BULLSEYE ); + picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this, board]( const VECTOR2D& pt ) -> bool diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 41002cec50..f4479a1859 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -3196,6 +3196,8 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS /// This allow the option of snapping in the tool picker->SetSnapping( true ); + picker->SetCursor( KICURSOR::PLACE ); + picker->ClearHandlers(); const auto setPickerLayerSet = [&]() diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index b4564cac34..47ca04ae25 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -763,6 +763,9 @@ int PCB_CONTROL::GridPlaceOrigin( const TOOL_EVENT& aEvent ) // Deactivate other tools; particularly important if another PICKER is currently running Activate(); + picker->SetCursor( KICURSOR::PLACE ); + picker->ClearHandlers(); + picker->SetClickHandler( [this]( const VECTOR2D& pt ) -> bool { @@ -803,6 +806,8 @@ int PCB_CONTROL::InteractiveDelete( const TOOL_EVENT& aEvent ) Activate(); picker->SetCursor( KICURSOR::REMOVE ); + picker->SetSnapping( false ); + picker->ClearHandlers(); picker->SetClickHandler( [this]( const VECTOR2D& aPosition ) -> bool diff --git a/pcbnew/tools/pcb_group_tool.cpp b/pcbnew/tools/pcb_group_tool.cpp index 2e7db9ab12..827c6cfde1 100644 --- a/pcbnew/tools/pcb_group_tool.cpp +++ b/pcbnew/tools/pcb_group_tool.cpp @@ -49,6 +49,10 @@ int PCB_GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent ) statusPopup.SetText( _( "Click on new member..." ) ); + picker->SetCursor( KICURSOR::BULLSEYE ); + picker->SetSnapping( false ); + picker->ClearHandlers(); + picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool { diff --git a/pcbnew/tools/pcb_picker_tool.cpp b/pcbnew/tools/pcb_picker_tool.cpp index 8cb42f670a..d5ba55169f 100644 --- a/pcbnew/tools/pcb_picker_tool.cpp +++ b/pcbnew/tools/pcb_picker_tool.cpp @@ -263,6 +263,10 @@ int PCB_PICKER_TOOL::SelectPointInteractively( const TOOL_EVENT& aEvent ) params.m_Receiver->UpdatePickedPoint( aPoint ); }; + SetSnapping( true ); + SetCursor( KICURSOR::PLACE ); + ClearHandlers(); + SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool { @@ -324,6 +328,10 @@ int PCB_PICKER_TOOL::SelectItemInteractively( const TOOL_EVENT& aEvent ) params.m_Receiver->UpdatePickedItem( aItem ); }; + SetCursor( KICURSOR::BULLSEYE ); + SetSnapping( false ); + ClearHandlers(); + SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool {