From af71c2d8771cd9fcbea489e37137005c1dd733ea Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 15 Dec 2022 13:47:28 +0000 Subject: [PATCH] Clear hover selections after command. Fixes https://gitlab.com/kicad/code/kicad/issues/13073 --- eeschema/tools/sch_editor_control.cpp | 21 ++++++++++++++++----- eeschema/tools/sch_editor_control.h | 7 ++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 7734fddf3c..f7dcb45a99 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -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& 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; diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index 41a3f54fff..7f9ab20c66 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -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.