Skip to content
Snippets Groups Projects
Commit 39a23fa9 authored by Jeff Young's avatar Jeff Young :flag_ua:
Browse files

Only eval numeric properties.

Fixes #13201
parent e68bb16a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment