← Back to team overview

kicad-developers team mailing list archive

[patch][eeschema] Show SPICE Netlist window should not be editable

 

Hello,

I noticed in simulation settings, that window displaying netlist for
simulation is editable. I think it is a bug and may be confusing for
user (typing random text didn't have influence on simulation)

See the attachment for a patch, where I fixed this and also added key
handler for wxStyledTextCtrl. Thanks to this window can be dismissed
when pressing Escape. 

Is it OK to share patch directly here or should I rather create bug
report? 

Best regards,
Sylwek
>From 7d3fcfa1a96c95ddab71850db3175e528158a966 Mon Sep 17 00:00:00 2001
From: Sylwester Kocjan <s.kocjan@xxxxx>
Date: Sun, 23 Jun 2019 16:28:31 +0200
Subject: [PATCH] eeschema: netlist view findow changed to read only and added
 ESC key handler

---
 eeschema/sim/sim_plot_frame.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp
index 6dfd664b5..751819211 100644
--- a/eeschema/sim/sim_plot_frame.cpp
+++ b/eeschema/sim/sim_plot_frame.cpp
@@ -1219,6 +1219,12 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
             EndModal( GetReturnCode() );
         }
 
+        void onEscape( wxKeyEvent& evt )
+        {
+            if( evt.GetKeyCode() == WXK_ESCAPE )
+                Close();
+        }
+
         NETLIST_VIEW_DIALOG(wxWindow* parent, wxString source) :
             wxDialog(parent, wxID_ANY, "SPICE Netlist",
                      wxDefaultPosition, wxSize(1500,900),
@@ -1236,14 +1242,17 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
             text->SetText( source );
 
             text->StyleClearAll();
+            text->SetReadOnly( true );
             text->SetLexer( wxSTC_LEX_SPICE );
 
             wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
             sizer->Add( text, 1, wxEXPAND );
             SetSizer( sizer );
 
-            Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( NETLIST_VIEW_DIALOG::onClose ), NULL,
-                    this );
+            Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( NETLIST_VIEW_DIALOG::onClose ),
+                    NULL, this );
+            text->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( NETLIST_VIEW_DIALOG::onEscape ),
+                    NULL, this );
         }
     };
 
-- 
2.17.1


Follow ups