Allow dialogs to veto mouse-warping when called from context menu.
Fixes: lp:1745731 * https://bugs.launchpad.net/kicad/+bug/1745731
This commit is contained in:
parent
dd17f24c04
commit
adf3637476
|
@ -26,6 +26,7 @@
|
|||
#include <kiway_player.h>
|
||||
#include <wx/evtloop.h>
|
||||
#include <pgm_base.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <eda_rect.h>
|
||||
#include <wx/display.h>
|
||||
#include <wx/grid.h>
|
||||
|
@ -92,6 +93,12 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
|
|||
// Inherit units from parent
|
||||
m_units = kiwayHolder->GetUserUnits();
|
||||
|
||||
// Don't mouse-warp after a dialog run from the context menu
|
||||
TOOL_MANAGER* toolMgr = kiwayHolder->GetToolManager();
|
||||
|
||||
if( toolMgr )
|
||||
toolMgr->VetoContextMenuMouseWarp();
|
||||
|
||||
// Set up the message bus
|
||||
SetKiway( this, &kiwayHolder->Kiway() );
|
||||
}
|
||||
|
|
|
@ -43,6 +43,12 @@ EDA_UNITS_T KIWAY_HOLDER::GetUserUnits() const
|
|||
}
|
||||
|
||||
|
||||
TOOL_MANAGER* KIWAY_HOLDER::GetToolManager() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// this is not speed critical, hide it out of line.
|
||||
void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway )
|
||||
{
|
||||
|
|
|
@ -689,6 +689,7 @@ 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<CONTEXT_MENU> menu( m->Clone() );
|
||||
|
@ -703,8 +704,8 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
|
|||
if( frame )
|
||||
frame->PopupMenu( menu.get() );
|
||||
|
||||
// Warp the cursor as long as the menu wasn't clicked out of
|
||||
if( menu->GetSelected() >= 0 )
|
||||
// Warp the cursor if a menu item was selected
|
||||
if( menu->GetSelected() >= 0 && m_warpMouseAfterContextMenu )
|
||||
m_viewControls->WarpCursor( m_menuCursor, true, false );
|
||||
// Otherwise notify the tool of a cancelled menu
|
||||
else
|
||||
|
|
|
@ -938,7 +938,7 @@ public:
|
|||
/**
|
||||
* Return the tool manager instance, if any.
|
||||
*/
|
||||
TOOL_MANAGER* GetToolManager() const { return m_toolManager; }
|
||||
TOOL_MANAGER* GetToolManager() const override { return m_toolManager; }
|
||||
|
||||
/**
|
||||
* A way to pass info to draw functions. the base class has no knowledge about
|
||||
|
|
|
@ -34,6 +34,7 @@ class KIWAY;
|
|||
class PROJECT;
|
||||
struct KIFACE;
|
||||
class KIFACE_I;
|
||||
class TOOL_MANAGER;
|
||||
|
||||
#define VTBL_ENTRY virtual
|
||||
|
||||
|
@ -78,6 +79,12 @@ public:
|
|||
*/
|
||||
VTBL_ENTRY EDA_UNITS_T GetUserUnits() const;
|
||||
|
||||
/**
|
||||
* Function GetToolManager
|
||||
* Return the tool manager instance, if any.
|
||||
*/
|
||||
VTBL_ENTRY TOOL_MANAGER* GetToolManager() const;
|
||||
|
||||
/**
|
||||
* Function SetKiway
|
||||
*
|
||||
|
|
|
@ -372,6 +372,12 @@ public:
|
|||
*/
|
||||
const KIGFX::VC_SETTINGS& GetCurrentToolVC() const;
|
||||
|
||||
void VetoContextMenuMouseWarp()
|
||||
{
|
||||
m_warpMouseAfterContextMenu = false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
|
||||
|
||||
|
@ -531,6 +537,8 @@ private:
|
|||
/// Right click context menu position.
|
||||
VECTOR2D m_menuCursor;
|
||||
|
||||
bool m_warpMouseAfterContextMenu;
|
||||
|
||||
/// Flag indicating whether a context menu is currently displayed.
|
||||
bool m_menuActive;
|
||||
|
||||
|
|
Loading…
Reference in New Issue