diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index ffd43c208e..e27d0b1ea6 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -689,7 +689,6 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) } m_viewControls->ForceCursorPosition( true, m_menuCursor ); - m_warpMouseAfterContextMenu = true; // Display a copy of menu std::unique_ptr menu( m->Clone() ); @@ -715,6 +714,9 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) dispatchInternal( evt ); } + // Restore setting in case it was vetoed + m_warpMouseAfterContextMenu = true; + // Notify the tools that menu has been closed TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CLOSED ); evt.SetParameter( m ); diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index a73a0ce214..3c529dbd00 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -372,6 +372,11 @@ public: */ const KIGFX::VC_SETTINGS& GetCurrentToolVC() const; + /** + * Disables mouse warping after the current context menu is closed. + * Must be called before invoking each context menu. + * It's a good idea to call this from non-modal dialogs (e.g. DRC window). + */ void VetoContextMenuMouseWarp() { m_warpMouseAfterContextMenu = false; diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 9f5afd07dc..f25439ab33 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -436,6 +436,7 @@ void DIALOG_DRC_CONTROL::doSelectionMenu( const DRC_ITEM* aItem ) } WINDOW_THAWER thawer( m_brdEditor ); + m_brdEditor->GetToolManager()->VetoContextMenuMouseWarp(); m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items ); // If we got an item, focus on it