Do not warp cursor to last location when footprint/text placement is activated from toolbar/menu.

Also makes the footprint appear instantly after closing the dialog.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9840
This commit is contained in:
dsa-t 2021-12-07 20:27:17 +03:00 committed by Jeff Young
parent 3d97138d92
commit a7193e0932
2 changed files with 20 additions and 2 deletions

View File

@ -968,6 +968,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = controls->GetCursorPosition();
bool reselect = false;
bool fromOtherCommand = fp != nullptr;
bool resetCursor = aEvent.HasPosition(); // Detect if activated from a hotkey.
// Prime the pump
if( fp )
@ -1078,7 +1079,15 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
commit.Add( fp );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, fp );
controls->SetCursorPosition( cursorPos, false );
// Reset cursor to the position before the dialog opened if activated from hotkey
if( resetCursor )
controls->SetCursorPosition( cursorPos, false );
// Other events must be from hotkeys or mouse clicks, so always reset cursor
resetCursor = true;
m_toolMgr->RunAction( ACTIONS::refreshPreview );
}
else
{

View File

@ -482,6 +482,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
bool resetCursor = aEvent.HasPosition(); // Detect if activated from a hotkey.
auto cleanup =
[&]()
{
@ -639,7 +641,6 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->Refresh();
}
m_controls->WarpCursor( text->GetPosition(), true );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
m_view->Update( &selection() );
@ -662,6 +663,14 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
}
m_controls->ForceCursorPosition( false );
// Reset cursor to the position before the dialog opened if activated from hotkey
if( resetCursor )
m_controls->SetCursorPosition( cursorPos, false );
// Other events must be from hotkeys or mouse clicks, so always reset cursor
resetCursor = true;
m_controls->ShowCursor( true );
m_controls->CaptureCursor( text != nullptr );
m_controls->SetAutoPan( text != nullptr );