diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 3cc3f779c9..e0ca81b831 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -74,6 +74,8 @@ UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, wxStaticText* aLabel, wxWindo nullptr, this ); m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), nullptr, this ); + m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( UNIT_BINDER::onClick ), nullptr, + this ); Connect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr, this ); @@ -130,21 +132,48 @@ void UNIT_BINDER::onUnitsChanged( wxCommandEvent& aEvent ) } +void UNIT_BINDER::onClick( wxMouseEvent& aEvent ) +{ + wxTextEntry* textEntry = dynamic_cast( m_valueCtrl ); + + if( textEntry && ( textEntry->GetValue() == INDETERMINATE_ACTION + || textEntry->GetValue() == INDETERMINATE_STATE ) ) + { + // These are tokens, not strings, so do a select all + textEntry->SelectAll(); + } + else + { + aEvent.Skip(); + } +} + + void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent ) { wxTextEntry* textEntry = dynamic_cast( m_valueCtrl ); - if( m_allowEval && textEntry ) + if( textEntry ) { - wxString oldStr = m_eval.OriginalText(); - - if( oldStr.length() && oldStr != textEntry->GetValue() ) + if( m_allowEval ) { - textEntry->SetValue( oldStr ); - textEntry->SetSelection( m_selStart, m_selEnd ); + wxString oldStr = m_eval.OriginalText(); + + if( oldStr.length() && oldStr != textEntry->GetValue() ) + { + textEntry->SetValue( oldStr ); + textEntry->SetSelection( m_selStart, m_selEnd ); + } + + m_needsEval = true; } - m_needsEval = true; + if( textEntry->GetValue() == INDETERMINATE_ACTION + || textEntry->GetValue() == INDETERMINATE_STATE ) + { + // These are tokens, not strings, so do a select all + textEntry->SelectAll(); + } } aEvent.Skip(); diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index f4e48be689..a51418f24a 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -195,6 +195,7 @@ public: } protected: + void onClick( wxMouseEvent& aEvent ); void onSetFocus( wxFocusEvent& aEvent ); void onKillFocus( wxFocusEvent& aEvent );