Fix long-standing issue with arrow keys moving in both axes.
This commit is contained in:
parent
d14950c3f8
commit
1f07505b27
|
@ -113,7 +113,7 @@ int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
|
||||||
wxFAIL_MSG( "CursorControl(): unexpected request" );
|
wxFAIL_MSG( "CursorControl(): unexpected request" );
|
||||||
}
|
}
|
||||||
|
|
||||||
getViewControls()->SetCursorPosition( cursor, true, true );
|
getViewControls()->SetCursorPosition( cursor, true, true, type );
|
||||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -487,7 +487,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
|
||||||
|
|
||||||
|
|
||||||
void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView,
|
void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView,
|
||||||
bool aTriggeredByArrows )
|
bool aTriggeredByArrows, long aArrowCommand )
|
||||||
{
|
{
|
||||||
m_updateCursor = false;
|
m_updateCursor = false;
|
||||||
|
|
||||||
|
@ -495,6 +495,7 @@ void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpV
|
||||||
{
|
{
|
||||||
m_settings.m_lastKeyboardCursorPositionValid = true;
|
m_settings.m_lastKeyboardCursorPositionValid = true;
|
||||||
m_settings.m_lastKeyboardCursorPosition = aPosition;
|
m_settings.m_lastKeyboardCursorPosition = aPosition;
|
||||||
|
m_settings.m_lastKeyboardCursorCommand = aArrowCommand;
|
||||||
m_cursorWarped = false;
|
m_cursorWarped = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -96,6 +96,9 @@ struct VC_SETTINGS
|
||||||
///> Is last cursor motion event coming from keyboard arrow cursor motion action
|
///> Is last cursor motion event coming from keyboard arrow cursor motion action
|
||||||
bool m_lastKeyboardCursorPositionValid;
|
bool m_lastKeyboardCursorPositionValid;
|
||||||
|
|
||||||
|
///> ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
|
||||||
|
long m_lastKeyboardCursorCommand;
|
||||||
|
|
||||||
///> Position of the above event
|
///> Position of the above event
|
||||||
VECTOR2D m_lastKeyboardCursorPosition;
|
VECTOR2D m_lastKeyboardCursorPosition;
|
||||||
};
|
};
|
||||||
|
@ -248,7 +251,8 @@ public:
|
||||||
* @param aPosition is the requested cursor position in the world coordinates.
|
* @param aPosition is the requested cursor position in the world coordinates.
|
||||||
* @param aWarpView enables/disables view warp if the cursor is outside the current viewport.
|
* @param aWarpView enables/disables view warp if the cursor is outside the current viewport.
|
||||||
*/
|
*/
|
||||||
virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true, bool aTriggeredByArrows = false ) = 0;
|
virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true,
|
||||||
|
bool aTriggeredByArrows = false, long aArrowCommand = 0 ) = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -85,7 +85,8 @@ public:
|
||||||
/// @copydoc VIEW_CONTROLS::GetRawCursorPosition()
|
/// @copydoc VIEW_CONTROLS::GetRawCursorPosition()
|
||||||
VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const override;
|
VECTOR2D GetRawCursorPosition( bool aSnappingEnabled = true ) const override;
|
||||||
|
|
||||||
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView, bool aTriggeredByArrows ) override;
|
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView,
|
||||||
|
bool aTriggeredByArrows, long aArrowCommand ) override;
|
||||||
|
|
||||||
/// @copydoc VIEW_CONTROLS::SetCrossHairCursorPosition()
|
/// @copydoc VIEW_CONTROLS::SetCrossHairCursorPosition()
|
||||||
void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView ) override;
|
void SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView ) override;
|
||||||
|
|
|
@ -323,7 +323,21 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent )
|
||||||
if( m_dragging && evt->Category() == TC_MOUSE )
|
if( m_dragging && evt->Category() == TC_MOUSE )
|
||||||
{
|
{
|
||||||
VECTOR2I mousePos( controls->GetMousePosition() );
|
VECTOR2I mousePos( controls->GetMousePosition() );
|
||||||
|
|
||||||
m_cursor = grid.BestSnapAnchor( mousePos, item_layers, sel_items );
|
m_cursor = grid.BestSnapAnchor( mousePos, item_layers, sel_items );
|
||||||
|
|
||||||
|
if( controls->GetSettings().m_lastKeyboardCursorPositionValid )
|
||||||
|
{
|
||||||
|
long action = controls->GetSettings().m_lastKeyboardCursorCommand;
|
||||||
|
|
||||||
|
// The arrow keys are by definition SINGLE AXIS. Do not allow the other
|
||||||
|
// axis to be snapped to the grid.
|
||||||
|
if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
|
||||||
|
m_cursor.y = prevPos.y;
|
||||||
|
else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
|
||||||
|
m_cursor.x = prevPos.x;
|
||||||
|
}
|
||||||
|
|
||||||
controls->ForceCursorPosition( true, m_cursor );
|
controls->ForceCursorPosition( true, m_cursor );
|
||||||
selection.SetReferencePoint( m_cursor );
|
selection.SetReferencePoint( m_cursor );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue