[ 1560860 ] wxComboCtrl EVT_TEXT filtering.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -638,6 +638,7 @@ void wxComboCtrlBase::Init()
|
||||
m_btnState = 0;
|
||||
m_btnWidDefault = 0;
|
||||
m_blankButtonBg = false;
|
||||
m_ignoreEvtText = 0;
|
||||
m_btnWid = m_btnHei = -1;
|
||||
m_btnSide = wxRIGHT;
|
||||
m_btnSpacingX = 0;
|
||||
@@ -709,6 +710,14 @@ wxComboCtrlBase::CreateTextCtrl(int style, const wxValidator& validator)
|
||||
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);
|
||||
@@ -1248,6 +1257,15 @@ wxBitmap& wxComboCtrlBase::GetBufferBitmap( const wxSize& sz ) const
|
||||
|
||||
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();
|
||||
@@ -1924,10 +1942,13 @@ wxString wxComboCtrlBase::GetValue() const
|
||||
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();
|
||||
@@ -1945,6 +1966,11 @@ void wxComboCtrlBase::SetValue(const wxString& value)
|
||||
}
|
||||
}
|
||||
|
||||
void wxComboCtrlBase::SetValue(const wxString& value)
|
||||
{
|
||||
SetValueWithEvent(value, false);
|
||||
}
|
||||
|
||||
// In this SetValue variant wxComboPopup::SetStringValue is not called
|
||||
void wxComboCtrlBase::SetText(const wxString& value)
|
||||
{
|
||||
@@ -1954,6 +1980,12 @@ void wxComboCtrlBase::SetText(const wxString& value)
|
||||
|
||||
m_valueString = value;
|
||||
|
||||
if ( m_text )
|
||||
{
|
||||
m_ignoreEvtText++;
|
||||
m_text->SetValue( value );
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user