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.
This commit is contained in:
Jeff Young 2022-10-31 10:42:22 +00:00
parent 1737a3b94e
commit 9eef638f0b
2 changed files with 2 additions and 65 deletions

View File

@ -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<SIM_LIBRARY> aLibrary,
std::shared_ptr<SIM_MODEL> aModel,
int aParamIndex )

View File

@ -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();
};