Only eval numeric properties.

Fixes https://gitlab.com/kicad/code/kicad/issues/13201
This commit is contained in:
Jeff Young 2022-12-27 12:30:28 +00:00
parent e68bb16a28
commit 39a23fa9bc
2 changed files with 17 additions and 7 deletions

View File

@ -98,7 +98,7 @@ SIM_STRING_PROPERTY::SIM_STRING_PROPERTY( const wxString& aLabel, const wxString
bool SIM_STRING_PROPERTY::OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event )
{
if( event.GetEventType() == wxEVT_SET_FOCUS )
if( event.GetEventType() == wxEVT_SET_FOCUS && allowEval() )
{
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wnd_primary );
@ -116,7 +116,7 @@ bool SIM_STRING_PROPERTY::OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_prima
return true;
}
}
else if( event.GetEventType() == wxEVT_KILL_FOCUS )
else if( event.GetEventType() == wxEVT_KILL_FOCUS && allowEval() )
{
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wnd_primary );
@ -154,19 +154,26 @@ wxValidator* SIM_STRING_PROPERTY::DoGetValidator() const
}
bool SIM_STRING_PROPERTY::allowEval() const
{
return m_valueType == SIM_VALUE::TYPE_INT
|| m_valueType == SIM_VALUE::TYPE_FLOAT;
}
bool SIM_STRING_PROPERTY::StringToValue( wxVariant& aVariant, const wxString& aText, int aArgFlags ) const
{
if( m_disabled )
return false;
wxString evaledText;
wxString text;
if( m_needsEval && m_eval.Process( aText ) )
evaledText = m_eval.Result();
if( allowEval() && m_needsEval && m_eval.Process( aText ) )
text = m_eval.Result();
else
evaledText = aText;
text = aText;
m_model.SetParamValue( m_paramIndex, std::string( evaledText.ToUTF8() ) );
m_model.SetParamValue( m_paramIndex, std::string( text.ToUTF8() ) );
aVariant = GetParam().value->ToString();
return true;

View File

@ -94,6 +94,9 @@ public:
bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event ) override;
protected:
bool allowEval() const;
protected:
SIM_VALUE::TYPE m_valueType;
SIM_VALUE_GRAMMAR::NOTATION m_notation;