From ed61c5593f8e57022921d1bcb3dda8b5f8cd2e3d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 11 Mar 2024 18:14:16 +0000 Subject: [PATCH] Don't show normal cut/copy/paste items in Signals grid. (Do allow a copy of signal names though.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/17395 --- eeschema/sim/simulator_frame_ui.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index ed330c8b78..cdf10483eb 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -50,6 +50,7 @@ #include #include #include "kiplatform/app.h" +#include "wx/clipbrd.h" SIM_TRACE_TYPE operator|( SIM_TRACE_TYPE aFirst, SIM_TRACE_TYPE aSecond ) @@ -168,11 +169,12 @@ void SIGNALS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) } menu.AppendSeparator(); + menu.Append( GRIDTRICKS_ID_COPY, _( "Copy Signal Name" ) + "\tCtrl+C" ); + + m_grid->PopupMenu( &menu ); } } } - - GRID_TRICKS::showPopupMenu( menu, aEvent ); } @@ -283,9 +285,25 @@ void SIGNALS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event ) for( const wxString& signal : signals ) m_parent->DoFourier( signal, fundamental ); } - else + else if( event.GetId() == GRIDTRICKS_ID_COPY ) { - GRID_TRICKS::doPopupSelection( event ); + wxLogNull doNotLog; // disable logging of failed clipboard actions + wxString txt; + + for( const wxString& signal : signals ) + { + if( !txt.IsEmpty() ) + txt += '\r'; + + txt += signal; + } + + if( wxTheClipboard->Open() ) + { + wxTheClipboard->SetData( new wxTextDataObject( txt ) ); + wxTheClipboard->Flush(); // Allow data to be available after closing KiCad + wxTheClipboard->Close(); + } } }