Hello,
I have subclassed wxComboBox to create my own vesion "wxComboBoxEx" that filters the content when the combobox text changes.
The problem is that, when I call Set() on the combobox within wxEVT_TEXT handler, it sends the wxEVT_TEXT again and I found myself in a recursive loop.
I want to Set() a wxComboBox item data without getting the wxEVT_TEXT event to be sent again.
TIA.
[wxMSW][3.1.3] How to Set a wxComboBox item data without getting the wxEVT_TEXT event to be sent? Topic is solved
Re: [wxMSW][3.1.3] How to Set a wxComboBox item data without getting the wxEVT_TEXT event to be sent?
virtual void wxComboBox::SetValue ( const wxString & text )
virtual
Sets the text for the combobox text field.
For normal, editable comboboxes with a text entry field calling this method will generate a wxEVT_TEXT event, consistently with wxTextEntry::SetValue() behaviour, use wxTextEntry::ChangeValue() if this is undesirable.
Use the source, Luke!
Re: [wxMSW][3.1.3] How to Set a wxComboBox item data without getting the wxEVT_TEXT event to be sent?
When I said: Set(), I was talking about wxItemContainer::Set() not wxTextEntry::SetValue(), that is the item data "wxArrayString" of the list box associated with the combobox.
For some reason wxEVT_TEXT is sent if I call wxItemContainer::Set(), and I don't like that behaviour.
For some reason wxEVT_TEXT is sent if I call wxItemContainer::Set(), and I don't like that behaviour.
Re: [wxMSW][3.1.3] How to Set a wxComboBox item data without getting the wxEVT_TEXT event to be sent?
Sorry, i overlooked that.
I don't see an easy solution for that. I'd try UnBind()ing the wxEVT_TEXT handler temporarily.
I don't see an easy solution for that. I'd try UnBind()ing the wxEVT_TEXT handler temporarily.
Use the source, Luke!
Re: [wxMSW][3.1.3] How to Set a wxComboBox item data without getting the wxEVT_TEXT event to be sent?
You solution gave me an idea:
May be I can do it like setting a bool member variable like bool m_bSetting to true before Set() and false after it, using the help of wxCriticalSectionLocker or wxMutexLocker and make an if (m_bSetting) check before I call Set().
I haven't tried it yet, but if it won't work, i will fall back to your solution.
May be I can do it like setting a bool member variable like bool m_bSetting to true before Set() and false after it, using the help of wxCriticalSectionLocker or wxMutexLocker and make an if (m_bSetting) check before I call Set().
I haven't tried it yet, but if it won't work, i will fall back to your solution.
Re: [wxMSW][3.1.3] How to Set a wxComboBox item data without getting the wxEVT_TEXT event to be sent?
That should work, too. A mutex should not be necessary as there are no threads involved.May be I can do it like setting a bool member variable like bool m_bSetting to true before Set() and false after it, using the help of wxCriticalSectionLocker or wxMutexLocker and make an if (m_bSetting) check before I call Set().
Use the source, Luke!