Added wxComboPopup::FindItem() to help in deciding how SetValue() should change the value of a read-only wxComboCtrl. This allows wxOwnerDrawnComboBox to have the same behavior as wxComboBox in that respect.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66409 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -590,6 +590,12 @@ void wxComboPopup::SetStringValue( const wxString& WXUNUSED(value) )
|
||||
{
|
||||
}
|
||||
|
||||
bool wxComboPopup::FindItem(const wxString& WXUNUSED(item),
|
||||
wxString* WXUNUSED(trueItem))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxComboPopup::LazyCreate()
|
||||
{
|
||||
return false;
|
||||
@@ -2575,12 +2581,26 @@ void wxComboCtrlBase::OnSetValue(const wxString& value)
|
||||
// to set the string value here (as well as sometimes in ShowPopup).
|
||||
if ( m_valueString != value )
|
||||
{
|
||||
m_valueString = value;
|
||||
bool found = true;
|
||||
wxString trueValue = value;
|
||||
|
||||
EnsurePopupControl();
|
||||
// Conform to wxComboBox behavior: read-only control can only accept
|
||||
// valid list items and empty string
|
||||
if ( m_popupInterface && HasFlag(wxCB_READONLY) && value.length() )
|
||||
{
|
||||
found = m_popupInterface->FindItem(value,
|
||||
&trueValue);
|
||||
}
|
||||
|
||||
if (m_popupInterface)
|
||||
m_popupInterface->SetStringValue(value);
|
||||
if ( found )
|
||||
{
|
||||
m_valueString = trueValue;
|
||||
|
||||
EnsurePopupControl();
|
||||
|
||||
if ( m_popupInterface )
|
||||
m_popupInterface->SetStringValue(trueValue);
|
||||
}
|
||||
}
|
||||
|
||||
Refresh();
|
||||
|
Reference in New Issue
Block a user