Don't use modifiers when moving with keyboard

The modifier keys on the keyboard control the motion spacing (Ctrl) and
shouldn't be confused with the modifier key used to disable grid
snapping when moving with the mouse (also Ctrl)

Fixes https://gitlab.com/kicad/code/kicad/issues/13027

(cherry picked from commit 4f6b853756)
This commit is contained in:
Seth Hillbrand 2022-11-28 11:04:03 -08:00
parent c9cc29593a
commit 2029fc4e8f
2 changed files with 17 additions and 11 deletions

View File

@ -353,7 +353,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
// Refresh the zoom level and mouse position on message panel // Refresh the zoom level and mouse position on message panel
// (mouse position has not changed, only the zoom level has changed): // (mouse position has not changed, only the zoom level has changed):
refreshMouse(); refreshMouse( true );
} }
else else
{ {
@ -371,7 +371,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
VECTOR2D delta( scrollX, scrollY ); VECTOR2D delta( scrollX, scrollY );
m_view->SetCenter( m_view->GetCenter() + delta ); m_view->SetCenter( m_view->GetCenter() + delta );
refreshMouse(); refreshMouse( true );
} }
// Do not skip this event, otherwise wxWidgets will fire // Do not skip this event, otherwise wxWidgets will fire
@ -545,7 +545,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir = m_view->ToWorld( dir, false ); dir = m_view->ToWorld( dir, false );
m_view->SetCenter( m_view->GetCenter() + dir ); m_view->SetCenter( m_view->GetCenter() + dir );
refreshMouse(); refreshMouse( true );
} }
break; break;
@ -766,7 +766,9 @@ void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordin
KIPLATFORM::UI::WarpPointer( m_parentPanel, aPosition.x, aPosition.y ); KIPLATFORM::UI::WarpPointer( m_parentPanel, aPosition.x, aPosition.y );
} }
refreshMouse(); // If we are not refreshing because of mouse movement, don't set the modifiers
// because we are refreshing for keyboard movement, which uses the same modifiers for other actions
refreshMouse( m_updateCursor );
} }
@ -894,7 +896,7 @@ void WX_VIEW_CONTROLS::handleCursorCapture( int x, int y )
} }
void WX_VIEW_CONTROLS::refreshMouse() void WX_VIEW_CONTROLS::refreshMouse( bool aSetModifiers )
{ {
// Notify tools that the cursor position has changed in the world coordinates // Notify tools that the cursor position has changed in the world coordinates
wxMouseEvent moveEvent( EVT_REFRESH_MOUSE ); wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
@ -902,10 +904,13 @@ void WX_VIEW_CONTROLS::refreshMouse()
moveEvent.SetX( msp.x ); moveEvent.SetX( msp.x );
moveEvent.SetY( msp.y ); moveEvent.SetY( msp.y );
// Set the modifiers state if( aSetModifiers )
moveEvent.SetControlDown( wxGetKeyState( WXK_CONTROL ) ); {
moveEvent.SetShiftDown( wxGetKeyState( WXK_SHIFT ) ); // Set the modifiers state
moveEvent.SetAltDown( wxGetKeyState( WXK_ALT ) ); moveEvent.SetControlDown( wxGetKeyState( WXK_CONTROL ) );
moveEvent.SetShiftDown( wxGetKeyState( WXK_SHIFT ) );
moveEvent.SetAltDown( wxGetKeyState( WXK_ALT ) );
}
m_cursorPos = GetClampedCoords( m_view->ToWorld( VECTOR2D( msp.x, msp.y ) ) ); m_cursorPos = GetClampedCoords( m_view->ToWorld( VECTOR2D( msp.x, msp.y ) ) );
wxPostEvent( m_parentPanel, moveEvent ); wxPostEvent( m_parentPanel, moveEvent );
@ -954,7 +959,7 @@ void WX_VIEW_CONTROLS::UpdateScrollbars()
// Trigger a mouse refresh to get the canvas update in GTK (re-draws the scrollbars). // Trigger a mouse refresh to get the canvas update in GTK (re-draws the scrollbars).
// Note that this causes an infinite loop on OSX and Windows (in certain cases) as it // Note that this causes an infinite loop on OSX and Windows (in certain cases) as it
// generates a paint event. // generates a paint event.
refreshMouse(); refreshMouse( false );
#endif #endif
} }
} }

View File

@ -151,8 +151,9 @@ private:
* It is mostly used for notifying the tools that the cursor position in the world * It is mostly used for notifying the tools that the cursor position in the world
* coordinates has changed, whereas the screen coordinates remained the same (e.g. * coordinates has changed, whereas the screen coordinates remained the same (e.g.
* frame edge autopanning). * frame edge autopanning).
* @param aSetModifiers If false, don't change the modifiers (they were set using the keyboard motion)
*/ */
void refreshMouse(); void refreshMouse( bool aSetModifiers);
/** /**
* Get the cursor position in the screen coordinates. * Get the cursor position in the screen coordinates.