Prevent jumping into disambiguation if moved

Moving points should not be overrided by disambiguation menu, so we
track where the disambiguation event started and only trigger the menu
if the mouse hasn't moved a full unit in x/y

Fixes https://gitlab.com/kicad/code/kicad/issues/9132
This commit is contained in:
Seth Hillbrand 2021-09-09 16:23:00 -07:00
parent 23024eb9e3
commit 29c2f3b7d4
5 changed files with 21 additions and 2 deletions

View File

@ -24,7 +24,6 @@
#include <tool/selection_tool.h>
SELECTION_TOOL::SELECTION_TOOL() :
m_additive( false ),
m_subtractive( false ),

View File

@ -347,8 +347,11 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Avoid triggering when running under other tools
if( m_frame->ToolStackIsEmpty() )
{
m_originalCursor = m_toolMgr->GetMousePosition();
m_disambiguateTimer.StartOnce( 500 );
}
}
// Single click? Select single object
else if( evt->IsClick( BUT_LEFT ) )
{
@ -729,6 +732,9 @@ int EE_SELECTION_TOOL::disambiguateCursor( const TOOL_EVENT& aEvent )
{
VECTOR2I pos = m_toolMgr->GetMousePosition();
if( pos != m_originalCursor )
return 0;
m_skip_heuristics = true;
SelectPoint( pos, EE_COLLECTOR::AllItems, nullptr, &m_canceledMenu, false, m_additive,
m_subtractive, m_exclusive_or );

View File

@ -25,7 +25,7 @@
#ifndef INCLUDE_TOOL_SELECTION_TOOL_H_
#define INCLUDE_TOOL_SELECTION_TOOL_H_
#include <math/vector2d.h>
#include <tool/tool_interactive.h>
#include <wx/timer.h>
@ -57,6 +57,8 @@ protected:
bool m_canceledMenu; // Sets to true if the disambiguation menu was cancelled
wxTimer m_disambiguateTimer; // Timer to show the disambiguate menu
VECTOR2I m_originalCursor; // Location of original cursor when starting click
};
#endif /* INCLUDE_TOOL_SELECTION_TOOL_H_ */

View File

@ -114,8 +114,11 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Avoid triggering when running under other tools
if( m_frame->ToolStackIsEmpty() )
{
m_originalCursor = m_toolMgr->GetMousePosition();
m_disambiguateTimer.StartOnce( 500 );
}
}
// Single click? Select single object
else if( evt->IsClick( BUT_LEFT ) )
{
@ -231,6 +234,9 @@ int PL_SELECTION_TOOL::disambiguateCursor( const TOOL_EVENT& aEvent )
{
VECTOR2I pos = m_toolMgr->GetMousePosition();
if( pos != m_originalCursor )
return 0;
m_skip_heuristics = true;
SelectPoint( pos, &m_canceledMenu );
m_skip_heuristics = false;

View File

@ -266,8 +266,11 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Avoid triggering when running under other tools
if( m_frame->ToolStackIsEmpty() )
{
m_originalCursor = m_toolMgr->GetMousePosition();
m_disambiguateTimer.StartOnce( 500 );
}
}
else if( evt->IsClick( BUT_LEFT ) )
{
// If there is no disambiguation, this routine is still running and will
@ -901,6 +904,9 @@ int PCB_SELECTION_TOOL::disambiguateCursor( const TOOL_EVENT& aEvent )
{
VECTOR2I pos = m_toolMgr->GetMousePosition();
if( pos != m_originalCursor )
return 0;
m_skip_heuristics = true;
selectPoint( pos, false, &m_canceledMenu );
m_skip_heuristics = false;