// (ie. wxComboPopup::SetStringValue doesn't get called).
void SetText(const wxString& value);
+ // This method sets value and also optionally sends EVT_TEXT
+ // (needed by combo popups)
+ void SetValueWithEvent(const wxString& value, bool withEvent = true);
+
//
// Popup customization methods
//
private:
void Init();
+ wxByte m_ignoreEvtText; // Number of next EVT_TEXTs to ignore
+
DECLARE_EVENT_TABLE()
DECLARE_ABSTRACT_CLASS(wxComboCtrlBase)
m_btnState = 0;
m_btnWidDefault = 0;
m_blankButtonBg = false;
+ m_ignoreEvtText = 0;
m_btnWid = m_btnHei = -1;
m_btnSide = wxRIGHT;
m_btnSpacingX = 0;
if ( HasFlag(wxTE_PROCESS_ENTER) )
style |= wxTE_PROCESS_ENTER;
+ // Ignore EVT_TEXT generated by the constructor (but only
+ // if the event redirector already exists)
+ // NB: This must be " = 1" instead of "++";
+ if ( m_textEvtHandler )
+ m_ignoreEvtText = 1;
+ else
+ m_ignoreEvtText = 0;
+
m_text = new wxTextCtrl(this, wxID_ANY, m_valueString,
wxDefaultPosition, wxDefaultSize,
style, validator);
void wxComboCtrlBase::OnTextCtrlEvent(wxCommandEvent& event)
{
+ if ( event.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED )
+ {
+ if ( m_ignoreEvtText > 0 )
+ {
+ m_ignoreEvtText--;
+ return;
+ }
+ }
+
// Change event id, object and string before relaying it forward
event.SetId(GetId());
wxString s = event.GetString();
return m_valueString;
}
-void wxComboCtrlBase::SetValue(const wxString& value)
+void wxComboCtrlBase::SetValueWithEvent(const wxString& value, bool withEvent)
{
if ( m_text )
{
+ if ( !withEvent )
+ m_ignoreEvtText++;
+
m_text->SetValue(value);
if ( !(m_iFlags & wxCC_NO_TEXT_AUTO_SELECT) )
m_text->SelectAll();
}
}
+void wxComboCtrlBase::SetValue(const wxString& value)
+{
+ SetValueWithEvent(value, false);
+}
+
// In this SetValue variant wxComboPopup::SetStringValue is not called
void wxComboCtrlBase::SetText(const wxString& value)
{
m_valueString = value;
+ if ( m_text )
+ {
+ m_ignoreEvtText++;
+ m_text->SetValue( value );
+ }
+
Refresh();
}