Clear hover selections after command.

Fixes https://gitlab.com/kicad/code/kicad/issues/13073
This commit is contained in:
Jeff Young 2022-12-15 13:47:28 +00:00
parent 5a7982161d
commit af71c2d877
2 changed files with 20 additions and 8 deletions

View File

@ -1560,15 +1560,18 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
}
bool SCH_EDITOR_CONTROL::doCopy( bool aUseLocalClipboard )
bool SCH_EDITOR_CONTROL::doCopy( bool aUseDuplicateClipboard )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
EE_SELECTION& selection = selTool->RequestSelection();
SCHEMATIC& schematic = m_frame->Schematic();
if( !selection.GetSize() )
if( selection.Empty() )
return false;
if( aUseDuplicateClipboard )
m_duplicateIsHoverSelection = selection.IsHover();
selection.SetScreen( m_frame->GetScreen() );
m_supplementaryClipboard.clear();
@ -1588,9 +1591,12 @@ bool SCH_EDITOR_CONTROL::doCopy( bool aUseLocalClipboard )
plugin.Format( &selection, &selPath, schematic, &formatter, true );
if( aUseLocalClipboard )
if( selection.IsHover() )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
if( aUseDuplicateClipboard )
{
m_localClipboard = formatter.GetString();
m_duplicateClipboard = formatter.GetString();
return true;
}
@ -1778,7 +1784,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
VECTOR2I eventPos;
if( aEvent.IsAction( &ACTIONS::duplicate ) )
content = m_localClipboard;
content = m_duplicateClipboard;
else
content = m_toolMgr->GetClipboardUTF8();
@ -2233,6 +2239,8 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
}
}
}
selection.SetIsHover( m_duplicateIsHoverSelection );
}
else
{
@ -2258,6 +2266,9 @@ int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
if( selection.GetSize() >= 1 )
symbol = (SCH_SYMBOL*) selection.Front();
if( selection.IsHover() )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
if( !symbol || symbol->GetEditFlags() != 0 )
return 0;

View File

@ -166,8 +166,8 @@ public:
const wxString& aSearchText );
private:
///< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true
bool doCopy( bool aUseLocalClipboard = false );
///< copy selection to clipboard or to m_duplicateClipboard
bool doCopy( bool aUseDuplicateClipboard = false );
bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
@ -228,7 +228,8 @@ private:
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
// Temporary storage location for Duplicate action
std::string m_localClipboard;
std::string m_duplicateClipboard;
bool m_duplicateIsHoverSelection;
// A map of sheet filename --> screens for the clipboard contents. We use these to hook up
// cut/paste operations for unsaved sheet content.