From 9eef638f0b779c2fdd28ca5e0359294b779bb293 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 31 Oct 2022 10:42:22 +0000 Subject: [PATCH] Don't validate on keystrokes. KiCad policy is to validate on focus-loss so that you can make changes which have intermediate states that are not valid. --- eeschema/sim/sim_property.cpp | 59 ++--------------------------------- eeschema/sim/sim_property.h | 8 ----- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/eeschema/sim/sim_property.cpp b/eeschema/sim/sim_property.cpp index 9ccc370b89..67177a2dd5 100644 --- a/eeschema/sim/sim_property.cpp +++ b/eeschema/sim/sim_property.cpp @@ -180,27 +180,12 @@ bool SIM_BOOL_VALIDATOR::Validate( wxWindow* aParent ) } -wxBEGIN_EVENT_TABLE( SIM_STRING_VALIDATOR, SIM_VALIDATOR ) - EVT_TEXT( wxID_ANY, SIM_STRING_VALIDATOR::onText ) - EVT_CHAR( SIM_STRING_VALIDATOR::onChar ) - EVT_MOUSE_EVENTS( SIM_STRING_VALIDATOR::onMouse ) -wxEND_EVENT_TABLE() - - SIM_STRING_VALIDATOR::SIM_STRING_VALIDATOR( SIM_VALUE::TYPE aValueType, SIM_VALUE_GRAMMAR::NOTATION aNotation ) : SIM_VALIDATOR(), m_valueType( aValueType ), - m_notation( aNotation ), - m_prevInsertionPoint( 0 ) + m_notation( aNotation ) { - wxTextEntry* textEntry = getTextEntry(); - - if( !textEntry ) - return; - - m_prevText = textEntry->GetValue(); - m_prevInsertionPoint = textEntry->GetInsertionPoint(); } @@ -216,6 +201,7 @@ bool SIM_STRING_VALIDATOR::Validate( wxWindow* aParent ) return true; wxTextEntry* const textEntry = getTextEntry(); + if( !textEntry ) return false; @@ -265,47 +251,6 @@ wxTextEntry* SIM_STRING_VALIDATOR::getTextEntry() } -void SIM_STRING_VALIDATOR::onText( wxCommandEvent& aEvent ) -{ - wxTextEntry* textEntry = getTextEntry(); - if( !textEntry ) - return; - - if( !isValid( textEntry->GetValue() ) ) - { - textEntry->ChangeValue( m_prevText ); - textEntry->SetInsertionPoint( m_prevInsertionPoint ); - } - - m_prevText = textEntry->GetValue(); - m_prevInsertionPoint = textEntry->GetInsertionPoint(); -} - - -void SIM_STRING_VALIDATOR::onChar( wxKeyEvent& aEvent ) -{ - aEvent.Skip(); - - wxTextEntry* textEntry = getTextEntry(); - if( !textEntry ) - return; - - m_prevInsertionPoint = textEntry->GetInsertionPoint(); -} - - -void SIM_STRING_VALIDATOR::onMouse( wxMouseEvent& aEvent ) -{ - aEvent.Skip(); - - wxTextEntry* textEntry = getTextEntry(); - if( !textEntry ) - return; - - m_prevInsertionPoint = textEntry->GetInsertionPoint(); -} - - SIM_PROPERTY::SIM_PROPERTY( std::shared_ptr aLibrary, std::shared_ptr aModel, int aParamIndex ) diff --git a/eeschema/sim/sim_property.h b/eeschema/sim/sim_property.h index 73b24194c4..74ddab541a 100644 --- a/eeschema/sim/sim_property.h +++ b/eeschema/sim/sim_property.h @@ -61,16 +61,8 @@ private: wxTextEntry* getTextEntry(); - void onText( wxCommandEvent& aEvent ); - void onChar( wxKeyEvent& aEvent ); - void onMouse( wxMouseEvent& aEvent ); - SIM_VALUE::TYPE m_valueType; SIM_VALUE_GRAMMAR::NOTATION m_notation; - wxString m_prevText; - long m_prevInsertionPoint; - - wxDECLARE_EVENT_TABLE(); };