diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 2a10f9c7e7..35683b0749 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -942,8 +942,13 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) if( wxWindow* frame = dynamic_cast( m_frame ) ) frame->PopupMenu( menu.get() ); - // If a menu is canceled then notify tool - if( menu->GetSelected() < 0 ) + // Warp the cursor if a menu item was selected + if( menu->GetSelected() >= 0 ) + { + if( m_viewControls && m_warpMouseAfterContextMenu ) + m_viewControls->WarpMouseCursor( m_menuCursor, true, false ); + } + // Otherwise notify the tool of a cancelled menu { TOOL_EVENT evt( TC_COMMAND, TA_CHOICE_MENU_CHOICE, -1 ); evt.SetHasPosition( false ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 41072f1263..89f0f4c1cf 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -2563,7 +2563,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) (int) new_items.size() ) ); // If items were duplicated, pick them up - if( doMoveSelection( aEvent, &commit ) ) + if( doMoveSelection( aEvent, &commit, true ) ) commit.Push( _( "Duplicate" ) ); else commit.Revert(); @@ -2629,13 +2629,13 @@ void EDIT_TOOL::FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, bool EDIT_TOOL::updateModificationPoint( PCB_SELECTION& aSelection ) { - if( m_dragging && aSelection.HasReferencePoint() ) - return false; - // Can't modify an empty group if( aSelection.Empty() ) return false; + if( ( m_dragging || aSelection[0]->IsMoving() ) && aSelection.HasReferencePoint() ) + return false; + // When there is only one item selected, the reference point is its position... if( aSelection.Size() == 1 ) { diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index 60f977806f..3b4c3773af 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -200,7 +200,7 @@ private: bool pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage, const wxString& aCanceledMessage, VECTOR2I& aReferencePoint ); - bool doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit ); + bool doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit, bool aAutoStart ); ///< Rebuilds the ratsnest for operations that require it outside the commit rebuild void rebuildConnectivity(); diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index c55d8ac8df..5ce316dff0 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -197,7 +197,7 @@ int EDIT_TOOL::PackAndMoveFootprints( const TOOL_EVENT& aEvent ) SpreadFootprints( &footprintsToPack, footprintsBbox.Normalize().GetOrigin(), false ); - if( doMoveSelection( aEvent, &commit ) ) + if( doMoveSelection( aEvent, &commit, true ) ) commit.Push( _( "Pack footprints" ) ); else commit.Revert(); @@ -219,7 +219,7 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent ) wxCHECK( aEvent.SynchronousState(), 0 ); aEvent.SynchronousState()->store( STS_RUNNING ); - if( doMoveSelection( aEvent, commit ) ) + if( doMoveSelection( aEvent, commit, true ) ) aEvent.SynchronousState()->store( STS_FINISHED ); else aEvent.SynchronousState()->store( STS_CANCELLED ); @@ -228,7 +228,7 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent ) { BOARD_COMMIT localCommit( this ); - if( doMoveSelection( aEvent, &localCommit ) ) + if( doMoveSelection( aEvent, &localCommit, false ) ) localCommit.Push( _( "Move" ) ); else localCommit.Revert(); @@ -277,7 +277,7 @@ VECTOR2I EDIT_TOOL::getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSo } -bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit ) +bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit, bool aAutoStart ) { bool moveWithReference = aEvent.IsAction( &PCB_ACTIONS::moveWithReference ); bool moveIndividually = aEvent.IsAction( &PCB_ACTIONS::moveIndividually ); @@ -544,7 +544,7 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved ); } - else if( !m_dragging && !evt->IsAction( &ACTIONS::refreshPreview ) ) + else if( !m_dragging && ( aAutoStart || !evt->IsAction( &ACTIONS::refreshPreview ) ) ) { // Prepare to start dragging editFrame->HideSolderMask();