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:
parent
1737a3b94e
commit
9eef638f0b
|
@ -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_STRING_VALIDATOR::SIM_STRING_VALIDATOR( SIM_VALUE::TYPE aValueType,
|
||||||
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
SIM_VALUE_GRAMMAR::NOTATION aNotation )
|
||||||
: SIM_VALIDATOR(),
|
: SIM_VALIDATOR(),
|
||||||
m_valueType( aValueType ),
|
m_valueType( aValueType ),
|
||||||
m_notation( aNotation ),
|
m_notation( aNotation )
|
||||||
m_prevInsertionPoint( 0 )
|
|
||||||
{
|
{
|
||||||
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;
|
return true;
|
||||||
|
|
||||||
wxTextEntry* const textEntry = getTextEntry();
|
wxTextEntry* const textEntry = getTextEntry();
|
||||||
|
|
||||||
if( !textEntry )
|
if( !textEntry )
|
||||||
return false;
|
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,
|
SIM_PROPERTY::SIM_PROPERTY( std::shared_ptr<SIM_LIBRARY> aLibrary,
|
||||||
std::shared_ptr<SIM_MODEL> aModel,
|
std::shared_ptr<SIM_MODEL> aModel,
|
||||||
int aParamIndex )
|
int aParamIndex )
|
||||||
|
|
|
@ -61,16 +61,8 @@ private:
|
||||||
|
|
||||||
wxTextEntry* getTextEntry();
|
wxTextEntry* getTextEntry();
|
||||||
|
|
||||||
void onText( wxCommandEvent& aEvent );
|
|
||||||
void onChar( wxKeyEvent& aEvent );
|
|
||||||
void onMouse( wxMouseEvent& aEvent );
|
|
||||||
|
|
||||||
SIM_VALUE::TYPE m_valueType;
|
SIM_VALUE::TYPE m_valueType;
|
||||||
SIM_VALUE_GRAMMAR::NOTATION m_notation;
|
SIM_VALUE_GRAMMAR::NOTATION m_notation;
|
||||||
wxString m_prevText;
|
|
||||||
long m_prevInsertionPoint;
|
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue